Skip to content

Commit

Permalink
removed_dead_animals
Browse files Browse the repository at this point in the history
  • Loading branch information
oboliziuk committed Oct 24, 2023
1 parent 40f7413 commit b259b85
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ def __init__(
self.hidden = hidden
Animal.alive.append(self)

def __setattr__(self, attr: str, value: int) -> None:
if attr == "health" and value <= 0 and self in Animal.alive:
Animal.alive.remove(self)
super().__setattr__(attr, value)

def __repr__(self) -> str:
return (f"{{"
f"Name: {self.name}, "
Expand All @@ -37,3 +32,5 @@ class Carnivore(Animal):
def bite(other: "Animal") -> None:
if isinstance(other, Herbivore) and not other.hidden:
other.health -= 50
if other.health <= 0:
Animal.alive.remove(other)

0 comments on commit b259b85

Please sign in to comment.