-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.cpp
172 lines (97 loc) · 3.52 KB
/
driver.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include<iostream>
#include<vector>
#include "models/Student_Staff.hpp"
#include "models/Student.hpp"
#include "models/Staff.hpp"
using namespace std;
void showStaff();
void showStudents();
Student_Staff * driver;
int main(){
cout<<" --------------------------------------------------------------\n";
cout<<" moodle simulator :)\n";
cout<<" --------------------------------------------------------------\n\n\n";
driver = new Student_Staff("db/student.txt","db/staff.txt");
int option;
while (true)
{
cout<<"\n\n***********************************************************************\n\n";
cout << "Controller Menu:" << endl;
cout << "1.Show Students info" << endl;
cout << "2.Show Staff info" << endl;
cout << "3.Find the highest gpa" << endl;
cout << "4.Find the undergrads" << endl;
cout << "5.Find staff with the same hired year" << endl;
cout << "0.exit" << endl;
option = -1;
while (true)
{
cout << "Please choose an option (0-5): ";
cin >> option;
if(option > -1 && option <6)
break;
cout << "invalid number !!!";
}
if(option == 0)
break;
else if(option == 1)
showStudents();
else if(option == 2)
showStaff();
else if(option == 3)
Student_Staff::Highest_GPA(driver->getStudents(),Student::num);
else if(option == 4){
vector<Student> undergrads = Student_Staff::N_of_UnderGrad(driver->getStudents(),Student::num);
cout << "the undergrad students are : \n\n";
for(Student s: undergrads){
s.Print_Std_Info();
}
}
else if(option == 5)
Student_Staff::Same_Hire_Year(driver->getStaff(),Staff::num);
}
free(driver);
return 0;
}
void showStaff(){
int option = 1;
Staff * staff = driver -> getStaff();
cout<< Staff::num <<"staff are registered in system\n";
while(true){
option = -1;
while (true)
{
cout<<"\n\nenter the index of the staff to show info or enter 0 to exit : ("<<Staff::num<<",0) ";
cin >> option;
if(0 <= option && option <= Staff::num)
break;
cout << "invalid number!!!";
}
if(option == 0)
break;
staff[option-1].Print_Stf_Info();
cout << "the staff salary is "<< staff[option -1 ].Calculate_Salary();
}
}
void showStudents(){
int option = 1;
Student * students = driver -> getStudents();
cout<< Student::num <<"students are registered in system\n";
while(true){
option = -1;
while (true)
{
cout<<"\n\nenter the index of the student to show info or enter 0 to exit : ("<<Student::num<<",0) ";
cin >> option;
if(0 <= option && option <= Student::num)
break;
cout << "invalid number!!!";
}
if(option == 0)
break;
students[option-1].Print_Std_Info();
cout<< "student status is " << students[option - 1].StudentStatus();
string completed = students[option - 1].CompleteProgram() ? "" : "not";
cout << "\nthe student has "<<completed<<" completed the program\n\n";
}
}