Skip to content

Commit

Permalink
Solution (3)
Browse files Browse the repository at this point in the history
  • Loading branch information
mishagitcode committed Oct 10, 2023
1 parent 2dcd77f commit 596bdbb
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,21 @@ def __init__(
self.hidden = hidden
Animal.alive.append(self)

def __str__(self) -> str:
def __repr__(self) -> str:
return ("{" + f"Name: {self.name}, "
f"Health: {self.health}, "
f"Hidden: {self.hidden}" + "}")


class Herbivore(Animal):
def hide(self) -> None:
if not self.hidden:
self.hidden = True
else:
self.hidden = False
self.hidden = not self.hidden


class Carnivore(Animal):
def bite(self, herb: Herbivore) -> None:

if type(herb) == Carnivore:
pass
elif not herb.hidden:
if isinstance(herb, Herbivore) and not herb.hidden:
herb.health -= 50

if herb.health <= 0:
Expand Down

0 comments on commit 596bdbb

Please sign in to comment.