Skip to content

Commit

Permalink
Solution4
Browse files Browse the repository at this point in the history
  • Loading branch information
MykytaPD09 committed Nov 4, 2023
1 parent 16173f0 commit 7ac9fa2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from typing import Optional


class Animal:
alive = []

def __init__(
self,
name: str,
health: int = 100,
hidden: bool = False
health: Optional[int] = 100,
hidden: Optional[bool] = False
) -> None:
self.name = name
self.health = health
Expand All @@ -29,6 +32,6 @@ def hide(self) -> None:


class Carnivore(Animal):
def bite(self, herbivore: "Herbivore") -> None:
def bite(self, herbivore: Herbivore) -> None:
if isinstance(herbivore, Herbivore) and not herbivore.hidden:
herbivore.reduce_health(50)

0 comments on commit 7ac9fa2

Please sign in to comment.