Created
December 13, 2016 13:40
-
-
Save anonymous/0751dc3eae8f264e12ea4564f0e71dd2 to your computer and use it in GitHub Desktop.
This file contains 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
@Override | |
Promise<Map<String, Double>> findPlayerWithMostMotms(List<Player> players) { | |
Map<String, Integer> mostManOfTheMatches = [:] | |
Integer currentlyMostManOfTheMatches = 0 | |
returnPlayerWithHighestAverageRating(players, mostManOfTheMatches, currentlyMostManOfTheMatches) | |
return Promise.value(mostManOfTheMatches) | |
} | |
private | |
static List<Player> returnPlayerWithHighestAverageRating(List<Player> players, Map<String, Integer> mostManOfTheMatches, Integer currentlyMostManOfTheMatches) { | |
players.each { | |
if (it.manOfTheMatches > currentlyMostManOfTheMatches) { | |
mostManOfTheMatches.clear() | |
mostManOfTheMatches.put(it.name, it.manOfTheMatches) | |
} | |
} | |
} | |
@Override | |
Promise<Map<String, Integer>> findMostCleanSheets(List<Player> players) { | |
Map<String, Integer> mostCleanSheets = [:] | |
Integer CurrentHighestValue = 0 | |
returnPlayerWithMostCleanSheets(players, mostCleanSheets, CurrentHighestValue) | |
return Promise.value(mostCleanSheets) | |
} | |
private | |
static List<Player> returnPlayerWithMostCleanSheets(List<Player> players, Map<String, Integer> mostCleanSheets, Integer CurrentHighestValue) { | |
players.each { | |
if (it.cleanSheets > CurrentHighestValue) { | |
mostCleanSheets.clear() | |
mostCleanSheets.put(it.name, it.cleanSheets) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment