Class ShowFlight
java.lang.Object
bcu.cmp5332.bookingsystem.commands.ShowFlight
- All Implemented Interfaces:
Command
The ShowFlight class represents a command to display detailed information about a specific flight.
It implements the Command interface, allowing it to be executed within the context of a FlightBookingSystem instance.
Upon execution, the command retrieves the flight information by its ID from the provided FlightBookingSystem instance. It then prints the long details of the flight using the getDetailsLong() method of the Flight class.
Example usage:
// Create a new ShowFlight command instance for flight with ID 1001
Command showFlightCommand = new ShowFlight(1001);
// Execute the command within a FlightBookingSystem instance
showFlightCommand.execute(flightBookingSystem);
-
Field Summary
Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command
HELP_MESSAGE
-
Constructor Summary
ConstructorDescriptionShowFlight
(int id) Constructs a ShowFlight command object with the specified flight ID. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(FlightBookingSystem flightBookingSystem) Executes the show flight details command within the provided FlightBookingSystem instance.
-
Constructor Details
-
ShowFlight
public ShowFlight(int id) Constructs a ShowFlight command object with the specified flight ID.- Parameters:
id
- The ID of the flight whose details are to be displayed
-
-
Method Details
-
execute
Executes the show flight details command within the provided FlightBookingSystem instance. Retrieves the flight information by its ID and prints its long details using the getDetailsLong() method.- 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
-