Skip to content

Commit

Permalink
'deleting-unusefull-class-type-annotations-into-bite-method-and-simpl…
Browse files Browse the repository at this point in the history
…ify-this-one'
  • Loading branch information
Dogober committed Dec 10, 2024
1 parent 005e21a commit dd57fcf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import annotations
from typing import Union


class Animal:
Expand Down Expand Up @@ -27,9 +26,8 @@ def hide(self) -> None:
class Carnivore(Animal):

@staticmethod
def bite(other: Union[Carnivore, Herbivore]) -> None:
if isinstance(other, Herbivore) and other.hidden:
return
other.health -= 50
if other.health <= 0:
Animal.alive.pop(Animal.alive.index(other))
def bite(other: Animal) -> None:
if isinstance(other, Herbivore) and not other.hidden:
other.health -= 50
if other.health <= 0:
Animal.alive.remove(other)

0 comments on commit dd57fcf

Please sign in to comment.