public Politician[] GetTotalOfVotes(VotesPerOffice[] results) { Politician[] totalVotes = CentralizeVotes(results); for (int i = 0; i < results.Length; i++) { for (int j = 0; j < totalVotes.Length; j++) { totalVotes[j].votes += results[i].office[j].votes; } } return totalVotes; }
private static Politician[] CentralizeVotes(VotesPerOffice[] results) { Politician[] total = new Politician[results[0].office.Length]; for (int i = 0; i < total.Length; i++) { total[i].name = results[0].office[i].name; total[i].votes = 0; } return total; }