-
Notifications
You must be signed in to change notification settings - Fork 0
/
candidate.cpp
127 lines (104 loc) · 2.01 KB
/
candidate.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "candidate.h"
Candidate::Candidate()
{
}
Candidate::Candidate(int id, QString n, QString p)
{
this->id = id;
name = n;
party = p;
surplus = 0;
status = 0;
surplusBeingDistributed = false;
}
void Candidate::increment_votes(int countNum, Vote *v)
{
votesPerCount[countNum].append(v);
}
void Candidate::set_votes(QList<Vote *> votes)
{
this->votes = votes;
votesPerCount.append(this->votes);
}
void Candidate::set_votes(QList<Vote *> votes, int index)
{
this->votes = votes;
votesPerCount[index] = this->votes;
}
QList<QList<Vote *>> Candidate::get_VotesPerCount()
{
return votesPerCount;
}
QList<Vote *> Candidate::get_votes_for_particular_count(int countNum)
{
return votesPerCount[countNum];
}
QList<Vote *> Candidate::get_votes_up_to_particular_count(int countNum)
{
QList<Vote *> temp;
for (int i = 0; i <= countNum; i++)
{
temp.append(votesPerCount[i]);
}
return temp;
}
QList<Vote *> Candidate::get_total_votes()
{
QList<Vote *> votes;
for (int i = 0; i < votesPerCount.size(); i++)
{
votes.append(votesPerCount[i]);
}
return votes;
}
int Candidate::get_id()
{
return id;
}
QString Candidate::get_Name()
{
return name;
}
QString Candidate::get_Party()
{
return party;
}
int Candidate::get_surplus()
{
return surplus;
}
void Candidate::set_surplus(int s)
{
surplus = s;
}
bool Candidate::get_surplusBeingDistributed()
{
return surplusBeingDistributed;
}
void Candidate::set_surplusBeingDistributed(bool d)
{
surplusBeingDistributed = d;
}
int Candidate::get_status()
{
return status;
}
void Candidate::set_status(int set)
{
status = set;
}
void Candidate::clear_votes()
{
for (int i = 0; i < votesPerCount.size(); i++)
{
votesPerCount[i].clear();
}
}
int Candidate::index_of_count_candidate_was_elected_in()
{
return votesPerCount.size()-1;
}
void Candidate::remove_vote()
{
votesPerCount[index_of_count_candidate_was_elected_in()].removeLast();
}