-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbite_319.py
More file actions
51 lines (43 loc) · 1.35 KB
/
bite_319.py
File metadata and controls
51 lines (43 loc) · 1.35 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
# TODO: Fix age and same_configuration functions (see test results)
class Car:
"""
Car class
-> Have a closer look at lines marked with '# *'
"""
def __init__(self, model, color):
self.model = model
self.color = color
def __eq__(self, other_car):
return (
self.model.lower() == other_car.model.lower()
and self.color.lower() == other_car.color.lower()
)
@staticmethod
def age(days):
"""if / elif / else for exercise sake, if there would
be more conditions we would use a dict / mapping
"""
if days == 7: # *
return "A week old"
elif days == 365: # *
return "A year old"
else:
return "Neither a week, nor a year old"
@staticmethod
def has_same_configuration(config1, config2):
if isinstance(config1, list) and isinstance(config2, list): # *
return config1 == config2 # *
else:
raise TypeError()
# TODO: Complete function
def is_same_car_color_and_model(car1, car2):
"""
Returns true if car1 and car2 are the of same model and color
"""
return car1 == car2
# TODO: Complete function
def is_same_instance_of_car(car1, car2):
"""
Returns true if car1 and car2 are exactly the same object (instance)
"""
return car1 is car2