Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for The Warriors by Parzifal
class Warrior:
def __init__(self, health = 50, attack = 5):
self.health = health
self.attack = attack
@property
def is_alive(self) -> bool:
return self.health > 0
def decrease_health(self, damage):
self.health -= damage
class Knight(Warrior):
def __init__(self, health = 50, attack = 7):
super().__init__(health, attack)
def fight(King_Arthur, Black_Knight):
attacker, defender = King_Arthur, Black_Knight
while (attacker.is_alive and defender.is_alive):
defender.decrease_health(attacker.attack)
defender, attacker = attacker, defender
return King_Arthur.is_alive
Oct. 16, 2018
Comments: