-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_1.py
57 lines (36 loc) · 1.33 KB
/
task_1.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
"""
First task of OO project.
Simply fill in some implementation details to learn about other important
OO features.
"""
class HelicopterParent:
"""A class which keeps a registry of all its sub-classes."""
children = []
# implement logic here to append the class object of each subclass
# to the children list.
class Getter:
"""A class with a dynamic property."""
def __init__(self, a, b):
self.a = a
self.b = b
# implement property c to be equal to a + b (even when a or b changes)
class Setter:
"""A class with dynamic attribute setting behavior."""
def __init__(self, a):
self.old_values_of_a = []
...
# implement a setter which appends the old values of a to the list
# 'old_values_of_a' each time a new value is set.
class RichParent:
"""A parent with lots of money."""
asset_1 = 10_000
asset_2 = 200_000
asset_3 = 600_000
# Implement a method called "get_net_worth" which adds up all asset values
# this should work even if new assets are added (e.g., asset_4 or
# asset_1022)
class ChildMoocher(RichParent):
"""A child class that inherits too much."""
siblings = 3
# Implement a method also called "get_net_worth" which calls the parent's
# get_net_worth function then returns the result divided by siblings.