Skip to content

Commit

Permalink
Changes in the 'bite' method with annotations and conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov-s-od committed Oct 11, 2023
1 parent f2e4cdc commit 14b6628
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def hide(self) -> None:

class Carnivore(Animal):
@staticmethod
def bite(herbivore: Herbivore) -> None:
if isinstance(herbivore, Herbivore) and herbivore.hidden is not True:
herbivore.health -= 50
def bite(victim: Animal) -> None:
if isinstance(victim, Herbivore) and not victim.hidden:
victim.health -= 50

if herbivore.health <= 0:
Animal.alive.remove(herbivore)
if victim.health <= 0:
Animal.alive.remove(victim)

0 comments on commit 14b6628

Please sign in to comment.