From 54c558310bc8f97aee5e1cb7ab975a99ae2f8e44 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Jun 2022 18:11:10 +0300 Subject: [PATCH 1/3] [#H15].(add hw animal) --- Shops/car_shop/HomeWork/animal.py | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Shops/car_shop/HomeWork/animal.py diff --git a/Shops/car_shop/HomeWork/animal.py b/Shops/car_shop/HomeWork/animal.py new file mode 100644 index 0000000..eb2e885 --- /dev/null +++ b/Shops/car_shop/HomeWork/animal.py @@ -0,0 +1,39 @@ +class Animal: + + + def __init__(self, name: str, age: int): + self.name = name + self.age = age + + +class Dog(Animal): + + + def __init__(self, name: str, age: int, favorite_command: str): + self.favorite_command = favorite_command + super().__init__(name, age) + + + + def make_command(self): + print(f"Hello, I'm {self.name}, and I'm woofing! My favorite command is {self.favorite_command}!") + + + +class Cat(Animal): + + + def __init__(self, name: str, age: int, favorite_place: str): + self.favorite_place = favorite_place + super().__init__(name, age) + + + def favorite_place(self): + print(f"Hello, I'm {self.name}, and I'm meowing! My favorite place is {self.favorite_place}!") + + +cat = Cat('Barsik', 2, 'Table') +cat.favorite_place() + +dog = Dog('Sharik', 5, 'Sit') +dog.make_command() From 9f591086477500edd80ae2033efd82e5de3349a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Jun 2022 10:42:13 +0300 Subject: [PATCH 2/3] [#H15] Added presentate --- Shops/car_shop/HomeWork/animal.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Shops/car_shop/HomeWork/animal.py b/Shops/car_shop/HomeWork/animal.py index eb2e885..7acdcf6 100644 --- a/Shops/car_shop/HomeWork/animal.py +++ b/Shops/car_shop/HomeWork/animal.py @@ -5,6 +5,10 @@ def __init__(self, name: str, age: int): self.name = name self.age = age + + def presentate(self): + print(f"My name is {self.name}, my age is {self.age}") + class Dog(Animal): @@ -23,17 +27,21 @@ def make_command(self): class Cat(Animal): - def __init__(self, name: str, age: int, favorite_place: str): - self.favorite_place = favorite_place + def __init__(self, name: str, age: int, fav_place: str): + self.fav_place = fav_place super().__init__(name, age) - def favorite_place(self): - print(f"Hello, I'm {self.name}, and I'm meowing! My favorite place is {self.favorite_place}!") + def sit_favorite_place(self): + print(f"Hello, I'm {self.name}, and I'm meowing! My favorite place is {self.fav_place}!") cat = Cat('Barsik', 2, 'Table') -cat.favorite_place() +cat.sit_favorite_place() +cat.presentate() dog = Dog('Sharik', 5, 'Sit') dog.make_command() +dog.presentate() + + From 77b9d1133506a6a1e6b9017c3221e0ee487002c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 10 Jun 2022 17:58:59 +0300 Subject: [PATCH 3/3] added 2 task --- Shops/car_shop/HomeWork/animal.py | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Shops/car_shop/HomeWork/animal.py b/Shops/car_shop/HomeWork/animal.py index 7acdcf6..92b609b 100644 --- a/Shops/car_shop/HomeWork/animal.py +++ b/Shops/car_shop/HomeWork/animal.py @@ -1,3 +1,4 @@ +# #Task 1 class Animal: @@ -45,3 +46,50 @@ def sit_favorite_place(self): dog.presentate() + +#Task 2 +from uuid import uuid4 + +class User: + + def __init__(self, name: str, age: int): + self.name = name + self.uuid = uuid4() + self.age = age + + +class Task: + + def __init__(self, description: str, sphere: str, experience: int): + self.description = description + self.sphere = sphere + self.experience = experience + + +class Employee(User): + + def __init__(self, name: str, age:int, sphere: str, experience:int): + self.sphere = sphere + self.experience = experience + super().__init__(name, age) + + + def task_execution(self, task: Task): + if (self.experience >= task.experience) and (self.sphere == task.sphere): + print(f"Task {task.description} is done!") + else: + print(f"Task {task.description} is not for me. ") + + +employee = Employee('Bob', 20, 'developer', 5) +task = Task('add OOP', 'developer', 5) + +employee.task_execution(task) + + + + + + + +