-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path12_review.py
103 lines (80 loc) · 2.04 KB
/
12_review.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from abc import ABC, abstractmethod
class AbstractEmployee(ABC):
new_id = 1
def __init__(self):
self.id = AbstractEmployee.new_id
AbstractEmployee.new_id += 1
@abstractmethod
def say_id(self):
pass
# script.py
#
# class User:
# def __init__(self):
# self._username = None
#
# @property
# def username(self):
# return self._username
#
# @username.setter
# def username(self, new_name):
# self._username = new_name
#
# class Meeting:
# def __init__(self):
# self.attendees = []
#
# def __add__(self, employee):
# print("{} added.".format(employee.username))
# self.attendees.append(employee.username)
#
# def __len__(self):
# return len(self.attendees)
#
# class Employee(AbstractEmployee, User):
# def __init__(self, username):
# super().__init__()
# User.__init__(self)
# self.username = username
#
# def say_id(self):
# print("My id is {}".format(self.id))
#
# def say_username(self):
# print("My username is {}".format(self.username))
from abc import ABC, abstractmethod
class AbstractEmployee(ABC):
new_id = 1
def __init__(self):
self.id = AbstractEmployee.new_id
AbstractEmployee.new_id += 1
@abstractmethod
def say_id(self):
...
class User:
def __init__(self):
self._username = None
@property
def username(self):
return self._username
@username.setter
def username(self, new_name):
self._username = new_name
class Meeting:
def __init__(self):
self.attendees = []
def __add__(self, employee):
print(f"{employee.username} added.")
self.attendees.append(employee.username)
def __len__(self):
return len(self.attendees)
class Employee(AbstractEmployee, User):
def __init__(self, username):
super().__init__()
User.__init__(self)
self.username = username
def say_id(self):
print(f"My id is {self.id}")
def say_username(self):
print(f"My username is {self.username}")