-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.cpp
39 lines (34 loc) · 1.14 KB
/
server.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "server.h"
namespace Mice {
Server::Server(std::string name, std::string id, std::string phone, double salary)
: Person(name, id, phone), _salary{salary}, _num_orders{0} { }
Server::Server(std::istream& ist) {
// The header must have been stripped from the incoming stream at this point
getline(ist, _name);
getline(ist, _id);
getline(ist, _phone);
ist >> _salary; ist.ignore();
ist >> _num_orders; ist.ignore();
}
void Server::save(std::ostream& ost) {
ost << "#" << std::endl << "SERVER" << std::endl; // header
ost << _name << std::endl;
ost << _id << std::endl;
ost << _phone << std::endl;
ost << _salary << std::endl;
ost << _num_orders << std::endl;
}
bool Server::fill_order_and_pay() {
++_num_orders;
return (_num_orders % PAY_PERIOD) == 0;
}
bool Server::restock_and_pay() {
_num_orders += 2;
return ((_num_orders % PAY_PERIOD) == 0)
|| (((_num_orders - 1) % PAY_PERIOD) == 0);
}
double Server::pay_server() { }
int Server::num_orders() {return _num_orders;}
int Server::salary() {return _salary;}
void Server::set_salary(double salary) {_salary = salary;}
}