-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Expand file tree
/
Copy pathbooking.py
More file actions
48 lines (39 loc) · 1.34 KB
/
booking.py
File metadata and controls
48 lines (39 loc) · 1.34 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
from datetime import datetime
from typing import List
from seat import Seat
from user import User
from concert import Concert
from enums import BookingStatus, SeatStatus
class Booking:
def __init__(self, id: str, user: User, concert: Concert, seats: List[Seat]):
self.id = id
self.user = user
self.concert = concert
self.seats = seats
self.totalPrice = sum(seat.price for seat in self.seats)
self.bookingStatus = BookingStatus.PENDING
def confirmBooking(self):
if self.bookingStatus == BookingStatus.PENDING:
self.bookingStatus = BookingStatus.CONFIRMED
for seat in self.seats:
seat.confirm_booking()
return True
def cancelBooking(self):
print(f"Booking {self.id} cancelled")
# Release all seats
for seat in self.seats:
seat.release()
self.bookingStatus = BookingStatus.CANCELLED
return True
def getId(self) -> str:
return self.id
def getUser(self) -> "User":
return self.user
def getConcert(self) -> "Concert":
return self.concert
def getSeats(self) -> List["Seat"]:
return self.seats
def getTotalPrice(self) -> float:
return self.totalPrice
def getStatus(self) -> "BookingStatus":
return