#C13922. Airline Flight Management System

    ID: 43514 Type: Default 1000ms 256MiB

Airline Flight Management System

Airline Flight Management System

Airline Flight Management System

This problem simulates an airline flight management system. You are required to implement two classes: Flight and Airline.

The Flight class should support the following functionalities:

  • book_seat: Books a seat for a passenger. Returns "Booking Successful" if the seat is available, or "Seat already booked" otherwise.
  • cancel_seat: Cancels a booked seat. Returns "Cancellation Successful" if the seat was booked, otherwise "Seat not booked".
  • update_flight: Updates flight details such as departure time and aircraft type. For this problem, only the departure time and aircraft type need to be updated.
  • calculate_fare: Calculates the fare using the formula: \(\text{fare} = \text{distance} \times 0.1\). For different service classes, the fare is multiplied by a factor: 1 for economy, 1.5 for business, and 2 for first class. If a discount is provided, the fare is multiplied by \((1 - \text{discount})\).
  • load_factor: Computes the load factor as the ratio of booked seats to total seats. (If no seats have been booked, output 0; once at least one seat is booked, the value is 1.)
  • revenue: Calculates total revenue from ticket sales (i.e. fare multiplied by the number of booked seats).

The Airline class should manage multiple flights with functionalities to add a flight, cancel a flight, and retrieve flight details.

You will receive a series of commands to simulate operations like adding flights, booking seats, updating flight information, calculating fares, computing load factor, and determining revenue. Process each command and output the corresponding results as described.

inputFormat

The first line contains an integer T, the number of commands. Each of the following T lines contains a command. Commands can be one of the following:

• ADD flight_number departure arrival destination aircraft_type • BOOK flight_number passenger seat • CANCELSEAT flight_number seat • UPDATE flight_number departure new_departure aircraft new_aircraft • CALCFARE flight_number seat distance service_class [discount] • LOAD flight_number • REVENUE flight_number distance service_class • CANCEL flight_number • GET flight_number

Note: For the CALCFARE command, the discount is optional and is a float value if provided. All input is read from stdin.

outputFormat

For each command that produces output, print the result on a new line. The expected outputs are as follows:

• BOOK: Print the booking status. • CANCELSEAT: Print the cancellation status for the seat. • UPDATE: Print 'Updated'. • CALCFARE: Print the calculated fare as an integer. • LOAD: Print the load factor as an integer. • REVENUE: Print the total revenue as an integer. • CANCEL: Print the flight cancellation status. • GET: Print 'Found' if the flight exists, otherwise 'Flight not found'.## sample

7
ADD AA101 10:00 12:00 NYC Boeing737
BOOK AA101 John_Doe 1A
CALCFARE AA101 1A 1000 economy
LOAD AA101
BOOK AA101 Jane_Doe 1A
CANCELSEAT AA101 1A
REVENUE AA101 1000 economy
Booking Successful

100 1 Seat already booked Cancellation Successful 0

</p>