Interface Command

All Known Implementing Classes:
AddBooking, AddCustomer, AddFeedback, AddFlight, ApplyPromocode, BookingWithName, CancelBooking, DeleteCustomer, DeleteFlight, Help, ListCustomer, ListFlights, LoadGUI, ShowCustomer, ShowFlight, ShowFlights, UpdateBooking, VIPSeatAllocation

public interface Command
The Command interface represents a command that can be executed within the flight booking system. Implementations of Command interface define specific operations such as adding a new flight, adding a new customer, cancelling a booking, etc.

The Command interface requires implementing classes to provide an execute method that executes the specific command within a FlightBookingSystem instance. This method may throw FlightBookingSystemException and IOException, indicating issues with executing the command or storing data, respectively.

The interface also defines a HELP_MESSAGE constant that provides a summary of available commands and their descriptions.

Example usage:


 // Create a new Command instance
 Command command = new AddFlight("ABC123", "New York", "London", LocalDate.now(), 200, 450.0);
 
 // Execute the command within a FlightBookingSystem instance
 command.execute(flightBookingSystem);
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    A help message that provides a summary of available commands and their descriptions.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(FlightBookingSystem flightBookingSystem)
    Executes the command within the provided FlightBookingSystem instance.
  • Field Details

    • HELP_MESSAGE

      static final String HELP_MESSAGE
      A help message that provides a summary of available commands and their descriptions. This message is intended to guide users on how to interact with the flight booking system.
      See Also:
  • Method Details

    • execute

      void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException
      Executes the command within the provided FlightBookingSystem instance. Implementing classes define specific operations to be performed within the system, such as adding a flight, cancelling a booking, etc.
      Parameters:
      flightBookingSystem - The FlightBookingSystem instance on which the command is to be executed
      Throws:
      FlightBookingSystemException - If there is an issue executing the command in the system
      IOException - If there is an error storing data using FlightBookingSystemData