-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVotingOffice.cpp
More file actions
68 lines (44 loc) · 1.75 KB
/
VotingOffice.cpp
File metadata and controls
68 lines (44 loc) · 1.75 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
#include "VotingOffice.h"
using namespace std;
VotingOffice::VotingOffice(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 << "VotingOffice Constructor" << endl;
}
VotingOffice::VotingOffice(std::string core_arg_host_url, std::string core_arg_owner_vsID, std::string core_arg_class_id, std::string core_arg_object_id, std::string votingOfficeName)
: Core(core_arg_host_url, core_arg_owner_vsID, core_arg_class_id, core_arg_object_id)
{
this->votingOfficeName = votingOfficeName;
this->registeredVoters.insert("0Wu");
}
vector<std::string> VotingOffice::getAuthMessage(std::string message, std::string machineId, std::string voterInfo){
//In the future: will need to add logic to check if machine Id is registered
vector<std::string> result;
if(registeredVoters.count(voterInfo) != 1){
result.push_back("Not Authorized");
result.push_back(voterInfo);
std::cout << voterInfo << " is not authorized to vote " << std::endl;
return result;
}
result.push_back("Authorized");
result.push_back(voterInfo);
return result;
}
vector<std::string> VotingOffice::getReceipt(std::string message, std::string machineId, std::string voterInfo){
//In the future: will need to add logic to check if machine Id is registered
vector<std::string> result;
if(message != "hasVoted"){
result.push_back("Hasn't Voted");
result.push_back(voterInfo);
return result;
}
if(registeredVoters.count(voterInfo) != 1){
result.push_back("Not Authorized");
result.push_back(voterInfo);
return result;
}
result.push_back("Done");
result.push_back(voterInfo);
return result;
}