From bc3080989e10fd8e80a40d42480e2bf55411479f Mon Sep 17 00:00:00 2001 From: Andriy_Shumskyy Date: Sat, 19 Aug 2023 20:21:12 +0300 Subject: [PATCH] solution --- app/__init__.py | 0 app/main.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 app/__init__.py diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/main.py b/app/main.py index 8fbf3053..b749543d 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,53 @@ -# write your code here +class Animal: + def __init__( + self, + name: str, + appetite: int, + is_hungry: bool = True + ) -> None: + self.name = name + self.appetite = appetite + self.is_hungry = is_hungry + + def print_name(self) -> None: + print(f"Hello, I'm {self.name}") + + def feed(self) -> int: + if self.is_hungry: + print(f"Eating {self.appetite} food points...") + self.is_hungry = False + return self.appetite + return 0 + + +class Cat(Animal): + def __init__( + self, + name: str, + is_hungry: bool = True + ) -> None: + super().__init__(name=name, is_hungry=is_hungry, appetite=3) + + @staticmethod + def catch_mouse() -> None: + print("The hunt began!") + + +class Dog(Animal): + def __init__( + self, + name: str, + is_hungry: bool = True + ) -> None: + super().__init__(name=name, is_hungry=is_hungry, appetite=7) + + @staticmethod + def bring_slippers() -> None: + print("The slippers delivered!") + + +def feed_animals(list_of_animals: list[Animal]) -> int: + sum_of_food_points = 0 + for animal in list_of_animals: + sum_of_food_points += animal.feed() + return sum_of_food_points