Class ShowFlights

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

public class ShowFlights extends Object implements Command
The ShowFlights class represents a command to display a list of flights with their short details. It implements the Command interface, allowing it to be executed within the context of a FlightBookingSystem instance.

Upon execution, the command retrieves the list of flights from the provided FlightBookingSystem instance using the getFlights() method. It then iterates through each flight in the list, checks if the flight is not marked as deleted (using getDeleteStatusFlight()), and prints its short details using getDetailsShort() method.

Finally, it prints the total number of flights displayed.

Example usage:


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

    • ShowFlights

      public ShowFlights()
  • Method Details

    • execute

      public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException
      Executes the show flights command within the provided FlightBookingSystem instance. Retrieves the list of flights, iterates through each flight, prints its short details if not deleted, and then prints the total number of flights displayed.
      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