Class ShowFlights
java.lang.Object
bcu.cmp5332.bookingsystem.commands.ShowFlights
- All Implemented Interfaces:
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);
-
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 show flights command within the provided FlightBookingSystem instance.
-
Constructor Details
-
ShowFlights
public ShowFlights()
-
-
Method Details
-
execute
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 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
-