Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyutillis committed Oct 16, 2023
1 parent 6c5fdfc commit 7a8d34b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


class Animal:
alive = []

Expand All @@ -11,9 +14,9 @@ def __init__(self,
Animal.alive.append(self)

def __repr__(self) -> str:
return f"{{Name: {self.name}, " \
f"Health: {self.health}, " \
f"Hidden: {self.hidden}}}"
return (f"{{Name: {self.name}, "
f"Health: {self.health}, "
f"Hidden: {self.hidden}}}")


class Herbivore(Animal):
Expand All @@ -23,7 +26,7 @@ def hide(self) -> None:

class Carnivore(Animal):
@staticmethod
def bite(herbivore: Animal) -> None:
def bite(herbivore: Herbivore | Carnivore) -> None:
if not (herbivore.hidden or isinstance(herbivore, Carnivore)):
herbivore.health -= 50
if herbivore.health <= 0:
Expand Down

0 comments on commit 7a8d34b

Please sign in to comment.