1 | <?php |
||
5 | class Ballot |
||
6 | { |
||
7 | /** |
||
8 | * Ranking of candidates ids. |
||
9 | * |
||
10 | * @var int[] |
||
11 | */ |
||
12 | protected $ranking; |
||
13 | |||
14 | /** |
||
15 | * The current weighting or value of this person's vote. |
||
16 | * |
||
17 | * @var float |
||
18 | */ |
||
19 | protected $weight; |
||
20 | |||
21 | /** |
||
22 | * The current preference in use from this ballot. |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $levelUsed; |
||
27 | |||
28 | /** |
||
29 | * Constructor. |
||
30 | * |
||
31 | * @param int[] $ranking The ranking of candidates Key being ranking, |
||
32 | * value being a candidate id. Zero-indexed (Key |
||
33 | * 0 for first choice) |
||
34 | */ |
||
35 | 11 | public function __construct(array $ranking) |
|
41 | |||
42 | /** |
||
43 | * Gets the Ranking of candidates ids. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | 4 | public function getRanking(): array |
|
51 | |||
52 | /** |
||
53 | * Gets the The current weighting or value of this person's vote. |
||
54 | * |
||
55 | * @return float |
||
56 | */ |
||
57 | 3 | public function getWeight(): float |
|
61 | |||
62 | /** |
||
63 | * Sets the The current weighting or value of this person's vote. |
||
64 | * |
||
65 | * @param float $weight The weight |
||
66 | * |
||
67 | * @return float $weight The inputted weight |
||
68 | */ |
||
69 | 2 | public function setWeight(float $weight): float |
|
75 | |||
76 | /** |
||
77 | * Gets the the current preference in use from this ballot. |
||
78 | * |
||
79 | * @return int |
||
80 | */ |
||
81 | 2 | public function getLevelUsed(): int |
|
85 | |||
86 | /** |
||
87 | * Sets the the current preference in use from this ballot. |
||
88 | * |
||
89 | * @return int |
||
90 | */ |
||
91 | 3 | public function incrementLevelUsed(): int |
|
97 | |||
98 | 2 | public function getLastChoice() |
|
108 | |||
109 | 2 | public function getNextChoice() |
|
119 | } |
||
120 |