/
main.cpp
83 lines (82 loc) · 1.79 KB
/
main.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
#include "class.h"
int main()
{
Student tempStudent;
Employee tempEmployee;
ifstream fin;
fin.open("persons");
char tempChar;
char* tempWord = new char[50];
int tempInt = -1;
int* tempArrInt = new int[10];
double tempDbl = -1.0;
for(int i = 0; i < 13; i++)
{
fin >> tempChar;
switch (tempChar)
{
case 's':
fin.get();
fin.getline(tempWord, 51, ':');
tempStudent.setFirstName(tempWord);
fin.getline(tempWord, 51, ':');
tempStudent.setLastName(tempWord);
fin >> tempInt;
tempStudent.setAge(tempInt);
fin.get();
for(int j = 0; j < 9; j++)
{
fin >> tempChar;
tempArrInt[j] = tempChar - '0';
}
tempStudent.setSSN(tempArrInt);
fin.get();
for(int j = 0; j < 10; j++)
{
fin >> tempChar;
tempArrInt[j] = tempChar - '0';
}
tempStudent.setNsheNumber(tempArrInt);
fin.get();
fin.get(tempWord, 51, ':');
tempStudent.setMajor(tempWord);
fin.get();
fin >> tempDbl;
tempStudent.setGpa(tempDbl);
tempStudent.print();
break;
case 'e':
fin.get();
fin.getline(tempWord, 51, ':');
tempEmployee.setFirstName(tempWord);
fin.getline(tempWord, 51, ':');
tempEmployee.setLastName(tempWord);
fin >> tempInt;
tempEmployee.setAge(tempInt);
fin.get();
for(int j = 0; j < 9; j++)
{
fin >> tempChar;
tempArrInt[j] = tempChar - '0';
}
tempEmployee.setSSN(tempArrInt);
fin.get();
for(int j = 0; j < 5; j++)
{
fin >> tempChar;
tempArrInt[j] = tempChar - '0';
}
tempEmployee.setEmployeeNumber(tempArrInt);
fin.get();
fin.get(tempWord, 51, ':');
tempEmployee.setTitle(tempWord);
fin.get();
fin >> tempInt;
tempEmployee.setSalary(tempInt);
tempEmployee.print();
break;
}
cout << endl;
}
return 0;
}