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:
flight_number (string)- represents the flight number (e.g.,"BA123").
destination (string)- represents the flight's destination.
seats_available (integer)- represents the number of available seats on the flight.
passenger_list (list)- represents a list of passengers on the flight.
Methods:
add_passenger(passenger)- adds a passenger to the flight's passenger list if there are
available seats.
get_available_seats()- returns the number of available seats on the flight.
Passenger Class Attributes:
Attributes:
name (string)- represents the name of the passenger.
passport_number (string)- represents the passport number of the passenger.Methods:
book_flight(flight, 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.
cancel_booking(flight, 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 "BA123" to "New York" with 100 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:
FirstName_FamilyName.py
Lab manual is allowed to open, but using the internet is not allowed.
 Question: you are required to create a simple Python program to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!