-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.cpp
More file actions
46 lines (38 loc) · 1.12 KB
/
user.cpp
File metadata and controls
46 lines (38 loc) · 1.12 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
42
43
44
45
46
#include <typeinfo>
#include <iostream>
#include "access_system.h"
#include "user.h"
class Room;
User::User(std::string name, std::string occupation, int age, AccessLevel accessibleLevel)
: name(name), occupation(occupation), age(age), accessibleLevel(accessibleLevel) {}
std::string User::getName() {
return name;
}
std::string User::getOccupation() {
return occupation;
}
int User::getAge() {
return age;
}
AccessLevel User::getAccessibleLevel() {
return accessibleLevel;
}
void User::goToRoom(Room* room) {
AccessSystem::sys.checkAccess(this, room);
}
void User::allowUser(User* user, Room* room) {
//Checking if this is an Admin
if (dynamic_cast<Admin*>(this)) {
AccessSystem::sys.grantCustomAccess(user, room);
} else {
std::cout << "Request to change the access level of user denied. Not enough rights.\n";
}
}
void User::forbidUser(User* user, Room* room) {
//Checking if this is an Admin
if (dynamic_cast<Admin*>(this)) {
AccessSystem::sys.withdrawAccess(user, room);
} else {
std::cout << "Request to change the access level of user denied. Not enough rights.\n";
}
}