-
Notifications
You must be signed in to change notification settings - Fork 0
/
family.py
42 lines (33 loc) · 1.09 KB
/
family.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
# encoding = utf-8
# person
from person import Accountor, Prgrammor
class Family(object):
def __init__(self) -> None:
super().__init__()
self.members = []
def add_person(self, new_person):
self.members.append(new_person)
def sum_of(self, item):
result_data = 0
for member in self.members:
result_data += getattr(member, item)
return result_data
def avg_of(self, item):
return self.sum_of(item) / len(self.members)
def who_big(self, item):
big_person = None
for member in self.members:
if big_person is not None:
big_person = member
elif getattr(member, item) > getattr(big_person, item):
big_person = member
return big_person
def start_work(self):
for member in self.members:
if type(member) is Accountor:
member.start_account()
elif type(member) is Prgrammor:
member.start_code()
def start_report(self):
for member in self.members:
member.report()