Skip to content

Commit

Permalink
'Solution2'
Browse files Browse the repository at this point in the history
  • Loading branch information
usKos committed Jul 14, 2023
1 parent f103949 commit 658cd53
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


class Animal:

def __init__(self, name: str,
Expand All @@ -16,8 +19,8 @@ def feed(self) -> int:
print(f"Eating {self.appetite} food points...")
self.is_hungry = False
return self.appetite
else:
return 0

return 0


class Cat(Animal):
Expand All @@ -41,11 +44,8 @@ def bring_slippers() -> None:
print("The slippers delivered!")


def feed_animals(list_animals: list) -> int:
sum_result = 0
for elem in list_animals:
if elem.is_hungry:
sum_result += elem.appetite
elem.feed()
def feed_animals(list_animals: list[Animal, Cat, Dog]) -> int:

return sum_result
return sum([elem.feed()
for elem in list_animals
if elem.is_hungry])

0 comments on commit 658cd53

Please sign in to comment.