From 908cff94aefc3d9a76d0b1a6028a99e20d4fc312 Mon Sep 17 00:00:00 2001 From: Borys Kirichenko Date: Thu, 24 Aug 2023 18:40:24 +0200 Subject: [PATCH 1/4] All tests passed --- app/main.py | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 8fbf3053..b2751c48 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,42 @@ -# 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, appetite=3, is_hungry=is_hungry) + + @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, appetite=7, is_hungry=is_hungry) + + @staticmethod + def bring_slippers() -> None: + print("The slippers delivered!") + + +def feed_animals(animals: list[Animal]) -> int: + return sum(Animal.feed(animal) for animal in animals) From 1a874c045dc074653850563b717f1be9fd459e11 Mon Sep 17 00:00:00 2001 From: Borys Kirichenko Date: Thu, 24 Aug 2023 18:40:24 +0200 Subject: [PATCH 2/4] def feed_animals fixed --- app/main.py | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 8fbf3053..7c83b10e 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,42 @@ -# 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, appetite=3, is_hungry=is_hungry) + + @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, appetite=7, is_hungry=is_hungry) + + @staticmethod + def bring_slippers() -> None: + print("The slippers delivered!") + + +def feed_animals(animals: list[Animal]) -> int: + return sum(animal.feed() for animal in animals) From a6200afbabbf499e38da5f577bc1c4887ba31647 Mon Sep 17 00:00:00 2001 From: Borys Kirichenko Date: Thu, 24 Aug 2023 19:18:46 +0200 Subject: [PATCH 3/4] def feed_animals fixed --- app/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/main.py b/app/main.py index 7c83b10e..f2cecccb 100644 --- a/app/main.py +++ b/app/main.py @@ -40,3 +40,4 @@ def bring_slippers() -> None: def feed_animals(animals: list[Animal]) -> int: return sum(animal.feed() for animal in animals) + From f7fb53900e14f49c8295a1280460f2e5ff00c23c Mon Sep 17 00:00:00 2001 From: Borys Kirichenko Date: Thu, 24 Aug 2023 19:19:01 +0200 Subject: [PATCH 4/4] def feed_animals fixed --- app/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/main.py b/app/main.py index f2cecccb..7c83b10e 100644 --- a/app/main.py +++ b/app/main.py @@ -40,4 +40,3 @@ def bring_slippers() -> None: def feed_animals(animals: list[Animal]) -> int: return sum(animal.feed() for animal in animals) -