-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.cpp
More file actions
41 lines (35 loc) · 1.63 KB
/
users.cpp
File metadata and controls
41 lines (35 loc) · 1.63 KB
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
#include "users.h"
#include "rooms.h"
//Including raw data about users from outside rather than storing it here
//In order not to make a mess in .cpp file
std::vector<userRaw> Users::usersRaw
#include "database.txt"
;
//Main user database which should be initialized
std::vector<User*> Users::database;
//Implementation of single method in Users class
void Users::initialize() {
for (auto& user : Users::usersRaw) {
//All substring which are to be found omit first letters to support upper and lower case
//We provide directors with personal cabinets, as well as admins and professors
if (user.occupation.find("ector") != -1) {
Users::database.push_back(new Director(user.name, user.occupation, user.age));
Rooms::database.push_back(new DirectorCabinet(user.name + "'s cabinet", Users::database.back()));
}
else if (user.occupation.find("dmin") != -1) {
Users::database.push_back(new Admin(user.name, user.age));
Rooms::database.push_back(new Cabinet(user.name + "'s cabinet", Users::database.back()));
}
else if (user.occupation.find("rofessor") != -1) {
Users::database.push_back(new Professor(user.name, user.occupation, user.subject, user.age, user.subjYears));
Rooms::database.push_back(new Cabinet(user.name + "'s cabinet", Users::database.back()));
}
else if (user.occupation.find("tudent") != -1) {
Users::database.push_back(new Student(user.name, user.occupation, user.subject, user.age, user.subjYears));
}
else {
//Others are lab employees
Users::database.push_back(new Employee(user.name, user.occupation, user.subject, user.age, user.subjYears));
}
}
}