From 06c90a889e3b8bbee8d910c8049d8436a3e9c340 Mon Sep 17 00:00:00 2001 From: KwintDimon <121832419+KwintDimon@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:47:37 +0200 Subject: [PATCH] Solution --- app/main.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 77067f0b..30da384d 100644 --- a/app/main.py +++ b/app/main.py @@ -1,16 +1,23 @@ class Animal: alive = [] - def __init__(self, name: str, health: str = 100) -> None: + def __init__( + self, + name: str, + health: str = 100, + hidden: bool = False + ) -> None: self.name = name self.health = health - self.hidden = False + self.hidden = hidden Animal.alive.append(self) def __repr__(self) -> str: - return (f"{{Name: {self.name}," - f" Health: {self.health}," - f" Hidden: {self.hidden}}}") + return ( + f"{{Name: {self.name}," + f" Health: {self.health}," + f" Hidden: {self.hidden}}}" + ) class Herbivore(Animal): @@ -19,7 +26,8 @@ def hide(self) -> None: class Carnivore(Animal): - def bite(self, animal: Herbivore) -> None: + @staticmethod + def bite(animal: Herbivore) -> None: if isinstance(animal, Herbivore): if not animal.hidden and animal.health > 0: animal.health -= 50