This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// step 1: find index of largest value | |
// If there is a tie, the last of the tied worlds will be chosen | |
World chosenWorld; | |
int maxVotes = int.MinValue, i = 0; | |
foreach (int votes in voteList) { | |
if ((chosenWorld == null) || (votes > maxVotes)) { | |
maxVotes = votes; | |
chosenWorld = worldList[i]; | |
} | |
i++; | |
} | |
// step 2: print the results, if you want | |
Server.Message("World {0} won with {1} votes!", chosenWorld.Name, maxVotes); | |
// step 3: there is no step 3, you're done | |
return chosenWorld; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment