Class ListFlights

java.lang.Object
bcu.cmp5332.bookingsystem.commands.ListFlights
All Implemented Interfaces:
Command

public class ListFlights extends Object implements Command
The ListFlights class represents a command to list all flights in the flight booking system. It implements the Command interface, allowing it to be executed within the context of a FlightBookingSystem instance.

Upon execution, the command retrieves a list of all flights from the FlightBookingSystem instance. It then iterates through the list and prints the short details (using getDetailsShort()) of each flight to the console, excluding any flights marked as deleted.

After listing all flights, it prints the total number of flights retrieved.

Example usage:


 // Create a new ListFlights command instance
 Command listFlightsCommand = new ListFlights();
 
 // Execute the command within a FlightBookingSystem instance
 listFlightsCommand.execute(flightBookingSystem);
 
See Also:
  • Constructor Details

    • ListFlights

      public ListFlights()
  • Method Details

    • execute

      public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException
      Executes the list flights command within the provided FlightBookingSystem instance. Retrieves a list of all flights and prints their short details to the console. Excludes flights marked as deleted.
      Specified by:
      execute in interface Command
      Parameters:
      flightBookingSystem - The FlightBookingSystem instance on which the command is executed
      Throws:
      FlightBookingSystemException - If there is an error while accessing or processing flight booking system data