From 7a8d34b786b0f75e18a7d2182f747fd0e74c4495 Mon Sep 17 00:00:00 2001 From: Lytillis Date: Mon, 16 Oct 2023 08:09:47 +0300 Subject: [PATCH] Minor changes --- app/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index dc0ea805..30923e52 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,6 @@ +from __future__ import annotations + + class Animal: alive = [] @@ -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): @@ -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: