Skip to content

Commit

Permalink
feat: solution
Browse files Browse the repository at this point in the history
  • Loading branch information
sashokpilipok7 committed Sep 29, 2023
1 parent 8a791ab commit 42e92a0
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ def __init__(self, name: str, health: int = None) -> None:
self.hidden = False
Animal.alive.append(self)

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


class Carnivore(Animal):
Expand All @@ -18,19 +21,11 @@ def check_is_alive(self, animal: Animal) -> None:
super().alive.remove(animal)

def bite(self, animal: Animal) -> None:
print(animal.hidden)
print(isinstance(animal, Herbivore) and not animal.hidden)
if isinstance(animal, Herbivore) and not animal.hidden:
print('bam')
animal.health -= 50
self.check_is_alive(animal)


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


lion = Animal("Lion King")
print(lion)
print(Animal.alive)

0 comments on commit 42e92a0

Please sign in to comment.