-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbooking.py
60 lines (49 loc) · 1.75 KB
/
booking.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
from hotel import Hotel
from driver import Driver
import datetime
class Booking:
def __init__(self, datetimeOfPickup, fromAirport, hotel, numPassengers):
self._hotel = hotel
self._numPassengers = numPassengers
self._driver = None
self._datetimeOfPickup = datetimeOfPickup
self._fromAirport = fromAirport
@property
def numPassengers(self):
return self._numPassengers
@property
def driver(self):
return self._driver
@property
def datetimeOfPickup(self):
return self._datetimeOfPickup
@property
def from_airport(self):
return self._fromAirport
@datetimeOfPickup.setter
def datatimeOfPickup(self, datetimeOfPickup):
self._datetimeOfPickup = datetimeOfPickup
@numPassengers.setter
def numPassengers(self, numPassengers):
self._numPassengers = numPassengers
@driver.setter
def driver(self, driver):
self._driver = driver
def __str__(self):
if self._driver:
driver = str(self.driver)
else:
driver = "No"
if self._fromAirport:
from_air = "To Hotel"
else:
from_air = "From Hotel"
return "Date/time" + str(self.datetimeOfPickup) + " " + from_air + "\n\t" + str(self._hotel) + " " \
+ str(self._numPassengers) + "\n\tAssigned: " + driver
if __name__ == "__main__":
booking_0 = Booking(datetime.datetime(2019, 12, 1, 12, 45), True, Hotel('Zenite', 'One Road P111'), 4)
print(booking_0.datetimeOfPickup)
booking_0.datatimeOfPickup += datetime.timedelta(hours=1)
print(booking_0.datetimeOfPickup)
print(booking_0._hotel._name)
print(str(booking_0))