From 42e92a033a8d16a1326a971162a0b79d4d25a80c Mon Sep 17 00:00:00 2001 From: Oleksandr Pylypenko Date: Fri, 29 Sep 2023 11:37:42 +0300 Subject: [PATCH] feat: solution --- app/main.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/main.py b/app/main.py index 09201858..59399f7e 100644 --- a/app/main.py +++ b/app/main.py @@ -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): @@ -18,10 +21,7 @@ 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) @@ -29,8 +29,3 @@ def bite(self, animal: Animal) -> None: class Herbivore(Animal): def hide(self) -> None: self.hidden = not self.hidden - - -lion = Animal("Lion King") -print(lion) -print(Animal.alive)