From 8c97b89f4f9372830207024d611a3ea84a3731ec Mon Sep 17 00:00:00 2001 From: Denys Date: Wed, 11 Oct 2023 08:36:32 +0200 Subject: [PATCH] del func remove_animal and fix bite func --- app/main.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/main.py b/app/main.py index dcdac46b..1fe1d8bf 100644 --- a/app/main.py +++ b/app/main.py @@ -16,18 +16,11 @@ def __repr__(self) -> str: f"Hidden: {self.hidden}}}" ) - def remove_animal(self) -> None: - if self in Animal.alive: - Animal.alive.remove(self) - class Herbivore(Animal): def hide(self) -> None: - if self.hidden is False: - self.hidden = True - else: - self.hidden = False + self.hidden = not self.hidden class Carnivore(Animal): @@ -35,5 +28,5 @@ class Carnivore(Animal): def bite(self, herbivore: Herbivore) -> None: if isinstance(herbivore, Herbivore) and not herbivore.hidden: herbivore.health -= 50 - if herbivore.health <= 0: - herbivore.remove_animal() + if herbivore.health <= 0: + Animal.alive.remove(herbivore)