Skip to content

Commit

Permalink
del func remove_animal and fix bite func
Browse files Browse the repository at this point in the history
  • Loading branch information
DenPrislipskyi committed Oct 11, 2023
1 parent 6816e02 commit 8c97b89
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@ 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):

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)

0 comments on commit 8c97b89

Please sign in to comment.