-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathb_developer.py
More file actions
52 lines (37 loc) · 1.92 KB
/
b_developer.py
File metadata and controls
52 lines (37 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Задания:
1. Создайте класс Developer, который будет наследоваться от класса ItDepartmentEmployee и класса SuperAdminMixin.
2. Переопределите у класса Developer метод __init__ таким образом, чтобы он на вход принимал еще и язык программирования.
3. Переопределите метод get_info у класса Developer таким образом, чтобы там выводился еще и язык программирования.
4. Вызовите у экземпляра класса Developer все возможные методы.
"""
class Employee:
def __init__(self, name: str, surname: str, age: int, salary: float):
self.name = name
self.surname = surname
self.age = age
self.salary = salary
def get_info(self):
return f"{self.name} with salary {self.salary}"
class ItDepartmentEmployee(Employee):
def __init__(self, name: str, surname: str, age: int, salary: float):
super().__init__(name, surname, age, salary)
self.salary *= 2
class AdminMixin:
def increase_salary(self, employee: Employee, amount: float):
employee.salary += amount
class SuperAdminMixin(AdminMixin):
def decrease_salary(self, employee: Employee, amount: float):
employee.salary -= amount
class Developer(ItDepartmentEmployee, SuperAdminMixin):
def __init__(self, name: str, surname: str, age: int, salary: float, lang: str):
super().__init__(name, surname, age, salary)
self.lang = lang
def get_info(self):
return f"{super().get_info()} by {self.lang}"
if __name__ == "__main__":
dev = Developer("denis", "pekshev", 40, 40000.0, "python")
print(dev.get_info())
dev.increase_salary(dev, 3000.0)
dev.decrease_salary(dev, 6000.0)
print(dev.get_info())