-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVotingMachine.cpp
More file actions
executable file
·74 lines (47 loc) · 1.83 KB
/
VotingMachine.cpp
File metadata and controls
executable file
·74 lines (47 loc) · 1.83 KB
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
#include "VotingMachine.h"
using namespace std;
VotingMachine::VotingMachine(std::string core_arg_host_url, std::string core_arg_owner_vsID, std::string core_arg_class_id, std::string core_arg_object_id)
: Core(core_arg_host_url, core_arg_owner_vsID, core_arg_class_id, core_arg_object_id)
{
cout << "VotingMachine Constructor" << endl;
}
VotingMachine::VotingMachine(std::string core_arg_host_url, std::string core_arg_owner_vsID, std::string core_arg_class_id, std::string core_arg_object_id, int votingMachineID)
: Core(core_arg_host_url, core_arg_owner_vsID, core_arg_class_id, core_arg_object_id)
{
this->votingMachineID = votingMachineID;
this->candidateA = 0;
this->candidateB = 0;
}
vector<std::string> VotingMachine::sendVoterInfo(std::string voterInfo){
vector<std::string> result;
result.push_back("requestingAuthorization");
result.push_back(to_string(this->votingMachineID));
result.push_back(voterInfo);
return result;
}
vector<std::string> VotingMachine::getBallot(std::string message, std::string voterInfo){
vector<std::string> result;
if(message != "Authorized"){
result.push_back("Nice try. You aren't authorized!");
result.push_back(voterInfo);
return result;
}
result.push_back("Candidate A");
result.push_back("Candidate B");
return result;
}
vector<std::string> VotingMachine::sendVote(std::string vote, std::string voterInfo){
vector<std::string> result;
if(vote == "Candidate A"){
candidateA++;
}else if(vote == "Candidate B"){
candidateB++;
}
cout << "Count for candidate A is " << candidateA << endl;
cout << "Count for candidate B is " << candidateB << endl;
cout << "" << endl;
result.push_back("hasVoted");
result.push_back(to_string(this->votingMachineID));
result.push_back(voterInfo);
return result;
}