Skip to content

Instantly share code, notes, and snippets.

Created December 13, 2016 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0751dc3eae8f264e12ea4564f0e71dd2 to your computer and use it in GitHub Desktop.
Save anonymous/0751dc3eae8f264e12ea4564f0e71dd2 to your computer and use it in GitHub Desktop.
@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