Class ListFlights
java.lang.Object
bcu.cmp5332.bookingsystem.commands.ListFlights
- All Implemented Interfaces:
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:
-
Field Summary
Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command
HELP_MESSAGE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the list flights command within the provided FlightBookingSystem instance.
-
Constructor Details
-
ListFlights
public ListFlights()
-
-
Method Details
-
execute
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 interfaceCommand
- 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
-