-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.py
76 lines (60 loc) · 2.13 KB
/
classes.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
67
68
69
70
71
72
73
74
75
76
class Vehicles:
count = 0
def __init__(self, vehicles):
self.vehicles = vehicles
Vehicles.count = len(self.vehicles)
def __len__(self):
return len(self.vehicles)
def __iter__(self):
return iter(self.vehicles)
def __getitem__(self, item):
return self.vehicles[item]
class Vehicle:
def __init__(self, id, vin, make, model, year, color, mileage, status, nextService, code=''):
# I decided to separate all the assignments for readability reasons.
self.id = id
self.vin = vin
self.make = make
self.model = model
self.year = year
self.color = color
self.mileage = mileage
self.status = status
self.nextservice = nextService
self.code = code
self.ra = 0 # Rental Agreement
def setcode(self, code):
"""Set the code on the vehicle"""
self.code = code
def domaintenance(self):
"""Do the maintenance"""
self.code = ''
def rentvehicle(self, ra):
self.ra = ra
def returnvehicle(self, mileage, qsp=''):
self.ra = 0
self.mileage += mileage
if qsp != '':
self.code = qsp + " " + self.code
def __str__(self):
"""Vehicle to string"""
return "{}:{} QSP: {}".format(self.id, self.vin, self.code)
class Reservation:
def __init__(self, id, start_date, end_date, car_class, location=None, renterid=None):
self.ra = id
self.rentdate = start_date
self.returndate = end_date
self.carclass = car_class
self.location = location
self.renterid = renterid
def __str__(self):
return "{}: {} to {}, {}. from {}, renter: {}".format(self.ra, self.rentdate, self.returndate, self.carclass,
self.location, self.renterid)
class Customer:
def __init__(self, id, first_name, last_name, email, address, company=None):
self.id = id
self.firstname = first_name
self.lastname = last_name
self.email = email
self.address = address
self.company = company