Skip to content

Commit

Permalink
Fix functions bite() [class Carnivore(Animal)], __repr__() [class Ani…
Browse files Browse the repository at this point in the history
…mal]
  • Loading branch information
frezworx committed Oct 11, 2023
1 parent 4af2edd commit 020242f
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ def __init__(
self.alive.append(self)

def __repr__(self) -> str:
return (f""
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 @@ -28,11 +29,9 @@ def hide(self) -> None:
class Carnivore(Animal):

def bite(self, animal: Animal) -> None:
if isinstance(animal, Carnivore):
return
if not isinstance(animal, Carnivore):
if not animal.hidden:
animal.health -= 50

if not animal.hidden:
animal.health -= 50

if animal.health <= 0:
animal.alive.remove(animal)
if animal.health <= 0:
animal.alive.remove(animal)

0 comments on commit 020242f

Please sign in to comment.