Skip to content

Commit

Permalink
Simplified Carnivore.bite method and removed test changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyutillis committed Oct 13, 2023
1 parent 9238722 commit d410032
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ def hide(self) -> None:


class Carnivore(Animal):
def bite(self, herbivore: Herbivore) -> None:
@staticmethod
def bite(herbivore: Herbivore) -> None:
if herbivore.hidden or isinstance(herbivore, Carnivore):
return
herbivore.health = max(0, herbivore.health - 50)
if not herbivore.health:
herbivore.health -= 50
if herbivore.health <= 0:
Animal.alive.pop(Animal.alive.index(herbivore))
2 changes: 0 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ def test_print_animal_alive():

f = io.StringIO()

print(Animal.alive)

with redirect_stdout(f):
print(Animal.alive)

Expand Down

0 comments on commit d410032

Please sign in to comment.