Question: class AirlineReservationSystem: def _ _ init _ _ ( self ) : self.firstClassSeats = [ [ ' ' for _ in range ( 4 )
class AirlineReservationSystem:
def initself:
self.firstClassSeats for in range for in range # rows, seats each
self.coachClassSeats for in range for in range # rows, seats each
self.firstClassPrice
self.coachClassPrice
self.taxRate # sales tax
def makereservationself classtype, row, seat, name, age, payment:
if classtype 'first':
price self.firstClassPrice
seats self.firstClassSeats
else:
price self.coachClassPrice
seats self.coachClassSeats
if seatsrowseat:
printSeat is unavailable."
return
if age or age :
price # Apply discount
totalcost price self.taxRate
if payment totalcost:
printInsufficient funds."
return
seatsrowseat name
change payment totalcost
self.calculatechangechange
printfReservation successful for name Change: $change:f
def calculatechangeself change:
denominations
changedistribution
for denom in denominations:
count intchange denom
changedistributiondenom count
change count denom
printChange distribution:", changedistribution
def changereservationself classtype, oldrow, oldseat, newrow, newseat, name:
if classtype 'first':
seats self.firstClassSeats
else:
seats self.coachClassSeats
if seatsoldrowoldseat name:
printNo reservation found for this seat."
return
if seatsnewrownewseat:
printNew seat is already taken."
return
seatsoldrowoldseat
seatsnewrownewseat name
printfReservation changed for name
def printseatsself:
printFirst Class Seats:"
for i row in enumerateselffirstClassSeats:
printfRow i: :formatname: for name in row
print
Coach Class Seats:"
for i row in enumerateselfcoachClassSeats:
printfRow i: :formatname: for name in row
def runself:
while True:
print
Options:"
printrf Make a first class reservation"
printrc Make a coach class reservation"
printcr Change an existing reservation"
printp Print the listing of seats"
printq Quit"
choice inputWhat would you like to do:
if choice rf:
row intinputEnter row :
seat intinputEnter seat :
name inputEnter name:
age intinputEnter age:
payment floatinputEnter payment amount:
self.makereservationfirst row, seat, name, age, payment
elif choice rc:
row intinputEnter row :
seat intinputEnter seat :
name inputEnter name:
age intinputEnter age:
payment floatinputEnter payment amount:
self.makereservationcoach row, seat, name, age, payment
elif choice cr:
classtype inputEnter class type firstcoach:
oldrow intinputEnter old row:
oldseat intinputEnter old seat:
newrow intinputEnter new row:
newseat intinputEnter new seat:
name inputEnter name:
self.changereservationclasstype, oldrow, oldseat, newrow, newseat, name
elif choice p:
self.printseats
elif choice q:
printExiting system."
break
else:
printInvalid option. Please try again."
system AirlineReservationSystem
system.run
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
