Skip to content

Commit

Permalink
repr
Browse files Browse the repository at this point in the history
  • Loading branch information
Familenko committed Oct 10, 2023
1 parent 12936ec commit 7ababe9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ def __init__(self, name: str,
self.health = health
self.hidden = hidden

self.alive.append(self)
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}}}")

def __repr__(self) -> str:
return self.__str__()


class Herbivore(Animal):

Expand All @@ -31,7 +28,7 @@ def hide(self) -> None:
class Carnivore(Animal):

@classmethod
def bite(cls, victim: "Herbivore") -> None:
def bite(cls, victim: Herbivore) -> None:
if not isinstance(victim, Carnivore) and not victim.hidden:
victim.health -= 50
if victim.health <= 0:
Expand Down

0 comments on commit 7ababe9

Please sign in to comment.