-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.cpp
107 lines (87 loc) · 1.38 KB
/
Person.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
#include "Person.hpp"
Person::Person(string _name, string _role, string _exact_role) : name(_name), role(_role), exact_role(_exact_role)
{
}
string Person::get_name()
{
return name;
}
string Person:: get_role()
{
return role;
}
string Person::get_exact_role()
{
return exact_role;
}
string Person::tell_role_to_detective()
{
return role;
}
bool Person::get_alive()
{
return alive;
}
void Person::die()
{
alive = false;
}
bool Person::get_healed()
{
return healed;
}
void Person::set_healed(bool state)
{
healed = state;
}
bool Person::get_silenced()
{
return silenced;
}
void Person::set_silenced()
{
silenced = true;
}
bool Person::get_extra_life()
{
return extra_life;
}
void Person::set_extra_life(bool state)
{
extra_life = state;
}
void Person::set_is_voted_to(Person* votee)
{
is_voted_to = votee;
}
Person* Person::get_is_voted_to()
{
return is_voted_to;
}
void Person::increase_gotten_votes()
{
++gotten_votes;
}
void Person::decrease_gotten_votes()
{
--gotten_votes;
}
void Person::empty_gotten_votes()
{
gotten_votes = 0;
}
int Person::get_gotten_votes()
{
return gotten_votes;
}
void Person::vote(Person* votee)
{
if(silenced)
throw MyException("This user has been silenced before");
if(!votee->get_alive())
throw MyException("User already died");
if(is_voted_to)
is_voted_to->decrease_gotten_votes();
is_voted_to = votee;
votee->increase_gotten_votes();
}