1 | <?php |
||
5 | class Candidate |
||
6 | { |
||
7 | const ELECTED = 1; |
||
8 | const RUNNING = 2; |
||
9 | const DEFEATED = 3; |
||
10 | |||
11 | /** |
||
12 | * Identifier for the candidate |
||
13 | * |
||
14 | * @var integer |
||
15 | */ |
||
16 | protected $id; |
||
17 | |||
18 | /** |
||
19 | * Number of votes the candidate currently has |
||
20 | * |
||
21 | * @var float |
||
22 | */ |
||
23 | protected $votes; |
||
24 | |||
25 | /** |
||
26 | * Number of surplus votes the candidate has to be re-allocated |
||
27 | * |
||
28 | * @var float |
||
29 | */ |
||
30 | protected $surplus; |
||
31 | |||
32 | /** |
||
33 | * State of the candidate (use class constants) |
||
34 | * |
||
35 | * @var integer |
||
36 | */ |
||
37 | protected $state; |
||
38 | |||
39 | /** |
||
40 | * Constructor |
||
41 | */ |
||
42 | 2 | public function __construct(int $id) |
|
49 | |||
50 | /** |
||
51 | * Gets the Identifier for the candidate. |
||
52 | * |
||
53 | * @return integer |
||
54 | */ |
||
55 | 1 | public function getId(): int |
|
59 | |||
60 | /** |
||
61 | * Gets the Number of votes the candidate currently has. |
||
62 | * |
||
63 | * @return float |
||
64 | */ |
||
65 | 1 | public function getVotes(): float |
|
69 | |||
70 | /** |
||
71 | * Sets the Number of votes the candidate currently has. |
||
72 | * |
||
73 | * @param float $votes the votes |
||
74 | * |
||
75 | * @return self |
||
76 | */ |
||
77 | protected function setVotes(float $votes) |
||
83 | |||
84 | /** |
||
85 | * Gets the Number of surplus votes the candidate has to be re-allocated. |
||
86 | * |
||
87 | * @return float |
||
88 | */ |
||
89 | 1 | public function getSurplus(): float |
|
93 | |||
94 | /** |
||
95 | * Sets the Number of surplus votes the candidate has to be re-allocated. |
||
96 | * |
||
97 | * @param float $surplus the surplus |
||
98 | * |
||
99 | * @return self |
||
100 | */ |
||
101 | protected function setSurplus(float $surplus) |
||
107 | |||
108 | /** |
||
109 | * Gets the State of the candidate (use class constants). |
||
110 | * |
||
111 | * @return integer |
||
112 | */ |
||
113 | 2 | public function getState(): int |
|
117 | |||
118 | /** |
||
119 | * Sets the State of the candidate (use class constants). |
||
120 | * |
||
121 | * @param integer $state the state |
||
122 | * |
||
123 | * @return self |
||
124 | */ |
||
125 | protected function setState(int $state) |
||
131 | } |
||
132 |