Question: Question: you are required to create a simple Python program to manage flight bookings. You need to define three classes: Flight, Passenger, and Booking. Flight
Question: you are required to create a simple Python program to manage flight bookings. You
need to define three classes: Flight, Passenger, and Booking.
Flight Class Attributes and Methods:
Attributes:
flightnumber string represents the flight number egBA
destination string represents the flight's destination.
seatsavailable integer represents the number of available seats on the flight.
passengerlist list represents a list of passengers on the flight.
Methods:
addpassengerpassenger adds a passenger to the flight's passenger list if there are
available seats.
getavailableseats returns the number of available seats on the flight.
Passenger Class Attributes:
Attributes:
name string represents the name of the passenger.
passportnumber string represents the passport number of the passenger.Methods:
bookflightflight passenger books a flight for a passenger if there are available
seats. It adds the passenger to the flight's passenger list and decreases the available
seats count.
cancelbookingflight passenger cancels a booking for a passenger on a flight. It
removes the passenger from the flight's passenger list and increases the available
seats count.
Your task:
Create a flight with flight number BA to "New York" with available seats.
Create three passengers with names and passport numbers.
Create an instance of the Booking class.
Book for the three passengers then cancel the booking of one of them
Print the flight's available seats and the list of passengers on the flight.
Notes:
The name of your python code must be in the following convention:
FirstNameFamilyName.py
Lab manual is allowed to open, but using the internet is not allowed.
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
