Basic game.
win("Charlie")
assert win("Foo") == "Foo has won!"
class KingAlbert:
"A game of King Albert for player `player`, using `win` and `lose`"
def __init__(self, player, status=(np.random.rand() > .5)):
self.player = player
self.status = status
def final_msg(self):
"Find out if you've won or lost"
return (win if self.status else lose)(self.player)
game = KingAlbert("Jenny", False)
game.final_msg()
game = KingAlbert("Bar", True)
assert game.final_msg() == "Bar has won!"