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 | * State of the candidate (use class constants) |
||
27 | * |
||
28 | * @var integer |
||
29 | */ |
||
30 | protected $state; |
||
31 | |||
32 | /** |
||
33 | * Constructor |
||
34 | */ |
||
35 | public function __construct(int $id) |
||
41 | |||
42 | 2 | /** |
|
43 | * Gets the Identifier for the candidate. |
||
44 | 2 | * |
|
45 | 2 | * @return integer |
|
46 | 2 | */ |
|
47 | 2 | public function getId(): int |
|
51 | |||
52 | /** |
||
53 | * Gets the Number of votes the candidate currently has. |
||
54 | * |
||
55 | 1 | * @return float |
|
56 | */ |
||
57 | 1 | public function getVotes(): float |
|
61 | |||
62 | /** |
||
63 | * Adds votes to a candidate |
||
64 | * |
||
65 | 1 | * @param float $votes Number of votes to add |
|
66 | * |
||
67 | 1 | * @return self |
|
68 | */ |
||
69 | public function addVotes(float $votes) |
||
75 | |||
76 | /** |
||
77 | * Gets the State of the candidate (use class constants). |
||
78 | * |
||
79 | * @return integer |
||
80 | */ |
||
81 | public function getState(): int |
||
85 | |||
86 | /** |
||
87 | * Sets the State of the candidate (use class constants). |
||
88 | * |
||
89 | 1 | * @param integer $state the state |
|
90 | * |
||
91 | 1 | * @return self |
|
92 | */ |
||
93 | public function setState(int $state) |
||
99 | } |
||
100 |