Class ShowFlight

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

public class ShowFlight extends Object implements 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);
 
See Also:
  • Field Summary

    Fields inherited from interface bcu.cmp5332.bookingsystem.commands.Command

    HELP_MESSAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
    ShowFlight(int id)
    Constructs a ShowFlight command object with the specified flight ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(FlightBookingSystem flightBookingSystem)
    Executes the show flight details command within the provided FlightBookingSystem instance.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException
      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 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