diff --git a/app/main.py b/app/main.py index c031efbf..050142d9 100644 --- a/app/main.py +++ b/app/main.py @@ -21,3 +21,19 @@ def __repr__(self) -> str: return (f"{{Name: {self.name}, " f"Health: {self.health}, " f"Hidden: {self.hidden}}}") + + +class Herbivore(Animal): + def hide(self) -> None: + self.hidden = False if self.hidden else True + + def bitten(self) -> None: + self.health -= 50 + self.is_dead() + + +class Carnivore(Animal): + def bite(self, other: Herbivore) -> None: + if not isinstance(other, Herbivore) or other.hidden: + return + other.bitten()