public VCSBallot[] getBallots() { if (ballots == null) { ballots = new List <VCSBallot>(); } VCSBallot[] ballotArray = new VCSBallot[ballots.Count()]; return(ballots.ToArray()); }
public void addBallot(VCSBallot ballot) { Debug.Assert(ballot != null, "Ballot is null"); if (ballots == null) { ballots = new List <VCSBallot>(); } // Notify the ballot that there will be no more changes ballot.didFinishAddingCandidatesToBallot(); // Add the ballot ballots.Add(ballot); updateView(); }
public void addBallot(VCSBallot ballot) { Debug.Assert(ballot != null, "Ballot is null"); if (ballots == null) { ballots = new List<VCSBallot>(); } // Notify the ballot that there will be no more changes ballot.didFinishAddingCandidatesToBallot(); // Add the ballot ballots.Add(ballot); updateView(); }
public void loadBallots() { Debug.Assert(ballotsFileScanner != null, "File can not be loaded"); VCSBallot ballot = new VCSBallot(); string line; while ((line = ballotsFileScanner.ReadLine()) != null) { int commaPosition = line.IndexOf(","); string candidatePreference = line.Substring(0, commaPosition); string candidateName = line.Substring(commaPosition + 1); // If we have got to the start of a new ballot if (candidatePreference.Equals("1")) { // If the ballot has at least one candidate, add it to the list of completed ballots if (ballot.hasAtLeastOneCandidate()) { addBallot(ballot); } // Initialise a new ballot ballot = new VCSBallot(); } ballot.addCandidateToBallot(getCandidateWithName(candidateName)); } // Add the final ballot addBallot(ballot); // Close the file ballotsFileScanner.Close(); ballotsFileScanner = null; }
public VCSBallot[] getBallots() { if (ballots == null) { ballots = new List<VCSBallot>(); } VCSBallot[] ballotArray = new VCSBallot[ballots.Count()]; return ballots.ToArray(); }