Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Shops/car_shop/HomeWork/animal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# #Task 1
class Animal:


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):


def __init__(self, name: str, age: int, favorite_command: str):
self.favorite_command = favorite_command
super().__init__(name, age)



def make_command(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше назвать действия животных одинаково, чтобы полиморфизм соблюдать

print(f"Hello, I'm {self.name}, and I'm woofing! My favorite command is {self.favorite_command}!")



Comment on lines +25 to +27
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

уменьшить до 2х пустых строк

class Cat(Animal):


def __init__(self, name: str, age: int, fav_place: str):
self.fav_place = fav_place
super().__init__(name, age)


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.sit_favorite_place()
cat.presentate()

dog = Dog('Sharik', 5, 'Sit')
dog.make_command()
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)








Comment on lines +88 to +95
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

оставить одну пустую строку