Class CancelBooking

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

public class CancelBooking extends Object implements Command
The CancelBooking class represents a command to cancel a booking for a specific customer on a specific flight. It implements the Command interface and requires execution within a FlightBookingSystem instance.

The booking cancellation is performed by invoking the cancelBooking method on the flightBookingSystem with the specified customer ID and flight ID. Upon cancellation, the system updates and stores the modified booking data using FlightBookingSystemData.

Example usage:


 int customerId = 1;
 int flightId = 101;
 Command cancelBookingCommand = new CancelBooking(customerId, flightId);
 cancelBookingCommand.execute(flightBookingSystem);
 
  • Field Summary

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

    HELP_MESSAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
    CancelBooking(int customerId, int flightId)
    Constructs a CancelBooking command with the specified customer ID and flight ID.
  • Method Summary

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

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CancelBooking

      public CancelBooking(int customerId, int flightId)
      Constructs a CancelBooking command with the specified customer ID and flight ID.
      Parameters:
      customerId - The ID of the customer whose booking is to be cancelled
      flightId - The ID of the flight for which the booking is to be cancelled
  • Method Details

    • execute

      public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException
      Executes the CancelBooking command within the provided FlightBookingSystem instance. Cancels the booking of the specified customer on the specified flight by invoking the cancelBooking method on flightBookingSystem. After cancellation, the updated booking data is stored using FlightBookingSystemData.
      Specified by:
      execute in interface Command
      Parameters:
      flightBookingSystem - The FlightBookingSystem instance on which the booking cancellation is to be executed
      Throws:
      FlightBookingSystemException - If there is an issue cancelling the booking in the system
      IOException - If there is an error storing data using FlightBookingSystemData