forked from jedbrooke/CIS-22C-Team-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmployee.cpp
119 lines (107 loc) · 2.38 KB
/
Employee.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Employee.cpp
* Vu Pham
*/
#include "Employee.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
using namespace std;
Employee::Employee() {
username = "";
password = "";
firstname = "";
lastname = "";
isEmployee = true;
}
Employee::Employee(string username, string password, string firstName, string lastName, bool isEmployee) {
this->username = username;
this->password = password;
this->firstname = firstName;
this->lastname = lastName;
this->isEmployee = isEmployee;
}
bool Employee::operator==(const Employee& employee) {
return (username == employee.username && password == employee.password);
}
bool Employee::operator<(const Employee& employee) {
if (firstname < employee.firstname)
return true;
else if (firstname == employee.firstname) {
if (lastname < employee.lastname)
return true;
else if (lastname == employee.lastname) {
if (username < employee.username)
return true;
else if (username == employee.username) {
if (password < employee.password)
return true;
else
return false;
}
else
return false;
}
else
return false;
}
else
return false;
}
bool Employee::operator>(const Employee& employee) {
if (firstname > employee.firstname)
return true;
else if (firstname == employee.firstname) {
if (lastname > employee.lastname)
return true;
else if (lastname == employee.lastname) {
if (username > employee.username)
return true;
else if (username == employee.username) {
if (password > employee.password)
return true;
else
return false;
}
else
return false;
}
else
return false;
}
else
return false;
}
void Employee::read(ifstream& in) {
string temp;
bool temp1;
in >> temp;
username = temp;
in >> temp;
password = temp;
in >> temp;
firstname = temp;
in >> temp;
lastname = temp;
in >> temp1;
isEmployee = temp1;
while (in.peek() == '\n')
in.get();
}
void Employee::write(ostream& out) {
out << username << '\n';
out << password << '\n';
out << firstname << '\n';
out << lastname << '\n';
out << isEmployee << '\n' << '\n';
}
ostream& operator<<(ostream& out, const Employee& employee) {
out << left << setw(15) << employee.firstname << employee.lastname << "\n";
return out;
}
string Employee::toString() const {
stringstream ss;
ss << username << "," << password << "," << firstname << "," << lastname;
return ss.str();
}