public bool Equals(Candidate c) { if (c.GetUid() == this.GetUid()) { return true; } return false; }
public int AddCandidate(Candidate c) { if (GetCandidateByUid(c.GetUid()) != null) { Log.PrintLog("Fail. Candidate UID already exist."); return -1; } CandidateList.Add(c); Log.PrintLog("Successfully added Candidate: " + c.GetUid()); return 0; }
public int GetGiveUps(Candidate c) { if (!restricted) { return 0; } int count = 0; for (int i = 0; i < RestrictList.Count; i++) { if (RestrictList[i].voted.Equals(c) && !IsExist(RestrictList[i], VoterList)) { count++; } } return count; }
public int MakeVote(Voter v, Candidate c) { if (restricted) { if (!IsExist(v, RestrictList)) { Log.PrintLog("Voter does not exist in the list."); return -1; } } Vote myVote = new Vote(this, v, c.GetUid()); if (HasVote(v)) { VoteList.Add(myVote); GetVoteByVoter(v).GetCandidate().DeleteVote(); VoteList.Remove(GetVoteByVoter(v)); c.AddVote(myVote); v.voted = c; Log.PrintLog("Already voted. Overwritten."); return 1; } VoteList.Add(myVote); c.AddVote(myVote); v.voted = c; Log.PrintLog("Vote Success. Voter: " + v.GetUid() + " Candidate: " + c.GetUid()); return 0; }