forked from elviscgn/FlightBooking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooking.py
More file actions
30 lines (19 loc) · 698 Bytes
/
booking.py
File metadata and controls
30 lines (19 loc) · 698 Bytes
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
from passenger import Passenger
from flight import Flight
class Booking:
def __init__(self, passenger, flight):
self.status = ""
self.passenger = passenger
self.flight = flight
def confirm(self):
if self.status == "Confirmed":
raise Exception
self.passenger.add_booking(self.flight)
self.flight.add_booking(self.passenger)
self.status = "Confirmed"
def cancel(self):
self.passenger.cancel_booking(self.flight)
self.flight.booked_passengers.remove(self.passenger)
self.status = "Cancelled"
def __str__(self):
return f"{self.passenger}, {self.flight}, {self.status}"