-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvehicles.py
66 lines (47 loc) · 1.79 KB
/
vehicles.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
from abc import ABC, abstractmethod
class Vehicle(ABC):
speed = {
'car' : 30,
'bike': 50,
'cng': 15
}
def __init__(self, vehicle_type, license_plate, rate, driver) -> None:
self.vehicle_type = vehicle_type
self.rate = rate
self.driver = driver
self.status = 'available'
self.license_plate = license_plate
self.speed = self.speed[vehicle_type]
@abstractmethod
def start_driving(self):
pass
@abstractmethod
def trip_finished(self):
pass
class Car(Vehicle):
def __init__(self, vehicle_type, license_plate, rate, driver) -> None:
super().__init__(vehicle_type, license_plate, rate, driver)
def start_driving(self):
self.status = 'unavailable'
print(self.vehicle_type, self.license_plate,'started')
def trip_finished(self):
self.status = 'available'
print(self.vehicle_type, self.license_plate, 'completed')
class Bike(Vehicle):
def __init__(self, vehicle_type, license_plate, rate, driver) -> None:
super().__init__(vehicle_type, license_plate, rate, driver)
def start_driving(self):
self.status = 'unavailable'
print(self.vehicle_type, self.license_plate,'started')
def trip_finished(self):
self.status = 'available'
print(self.vehicle_type, self.license_plate, 'completed')
class Cng(Vehicle):
def __init__(self, vehicle_type, license_plate, rate, driver) -> None:
super().__init__(vehicle_type, license_plate, rate, driver)
def start_driving(self):
self.status = 'unavailable'
print(self.vehicle_type, self.license_plate,'started')
def trip_finished(self):
self.status = 'available'
print(self.vehicle_type, self.license_plate, 'completed')