-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvanced Classes ABC.py
More file actions
54 lines (40 loc) · 1.14 KB
/
Copy pathAdvanced Classes ABC.py
File metadata and controls
54 lines (40 loc) · 1.14 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
53
54
from abc import ABC
from abc import abstractmethod
class Vehicle(ABC):
def __init__(
self,
brand_name: str,
year_of_issue: int,
base_price: int,
mileage: int
):
self.brand_name = brand_name
self.year_of_issue = year_of_issue
self.base_price = base_price
self.mileage = mileage
@abstractmethod
def wheels_num(self) -> int:
return 0
def vehicle_type(self) -> str:
return f'{self.brand_name} {self.__class__.__name__}'
def is_motorcycle(self) -> bool:
return (self.wheels_num() == 2)
@property
def purchase_price(self) -> float:
return max(100_000.0, (self.base_price - 0.1 * self.mileage))
# Don't change class implementation
class Car(Vehicle):
def wheels_num(self):
return 4
# Don't change class implementation
class Motorcycle(Vehicle):
def wheels_num(self):
return 2
# Don't change class implementation
class Truck(Vehicle):
def wheels_num(self):
return 10
# Don't change class implementation
class Bus(Vehicle):
def wheels_num(self):
return 6