public void DelegateVote(IVoter fromWhom, IVoter toWhom) { FindVoterResult voterResult = findVoter(fromWhom); if (voterResult.IsFound) { voterResult.VoterItem.DelegateToVoter = toWhom; } else { fromWhom.DelegateToVoter = toWhom; AddVoter(fromWhom); } }
bool AreVotesInvalidForVoter(IVoter voter) { HashSet <IVoter> uniqueVoters = new HashSet <IVoter>(); FindVoterResult voterResult = findVoter(voter); while (voterResult.IsFound) { if (uniqueVoters.Contains(voterResult.VoterItem)) { return(true); } uniqueVoters.Add(voterResult.VoterItem); voterResult = findVoter(voterResult.VoterItem.DelegateToVoter); } return(false); }