-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscientist.cpp
50 lines (46 loc) · 1.28 KB
/
scientist.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
#include "scientist.h"
Scientist::Scientist()
{
}
//Reads scientist from a delimited string
Scientist Scientist::fromString(string s, char delim){
stringstream ss(s), dateStream;
string item;
int i = 0;
Scientist sci;
while (getline(ss, item, delim)) {
switch(i){
case 0:
sci.firstName = item;
break;
case 1:
sci.lastName = item;
break;
case 2:
sci.gender = item[0];
break;
case 3:
sci.birthdate = Date::fromString(item);
break;
case 4:
sci.deathdate = Date::fromString(item);
break;
case 5:
sci.nationality = item;
break;
default:
break;
}
i++;
}
return sci;
}
bool operator ==(const Scientist &a, const Scientist &b){
if(a.firstName != b.firstName) return false;
else if (a.lastName != b.lastName) return false;
else if (a.gender != b.gender) return false;
else if (a.birthdate != b.birthdate) return false;
else if (a.deathdate != b.deathdate) return false;
else if (a.nationality != b.nationality) return false;
return true;
}