Created
June 23, 2017 18:39
-
-
Save echiesse/7643c50c7361a7f6fe8773eeabe83c27 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
class Player: | |
def __init__(self, name, customMsg = "com"): | |
self.score = 0 | |
self.name = name | |
self.customMsg = customMsg | |
def __str__(self): | |
return "{}: {} pontos".format(self.name, self.score) | |
def getWinner(players): | |
candidates = list(filter(lambda player: player.score <= 21, players)) # Elimina quem estourou | |
eliminated = list(filter(lambda player: player.score > 21, players)) # Lista de quem estourou | |
for player in eliminated: | |
print(player.name + " estourou") | |
winner = None | |
if len(candidates) == 0: | |
print("Não foi dessa vez jogadores...") | |
else: | |
winner = max(candidates, key = lambda c: c.score) | |
print("O jogador {} venceu a partida {} {} pontos".format(winner.name, winner.customMsg, winner.score)) | |
p1 = Player("Mario") | |
p1.score = 15 | |
p2 = Player("Antonio") | |
p2.score = 16 | |
p3 = Player("Roberto") | |
p3.score = 22 | |
getWinner([p1, p2, p3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment