Class ApplyPromocode

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

public class ApplyPromocode extends Object implements Command
The ApplyPromocode class represents a command to apply a promotional code to a flight in the flight booking system.

The promotional code is applied to a flight identified by its booking ID. Upon execution, the system retrieves the booking with the specified ID, applies the promotional code to its associated flight, and stores the updated data using FlightBookingSystemData.

Example usage:


 int bookingID = 21;
 String promocode = "nabinOpensFlightCompany20";
 Command applyPromocodeCommand = new ApplyPromocode(bookingID, promocode);
 applyPromocodeCommand.execute(flightBookingSystem);
 
  • Field Summary

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

    HELP_MESSAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
    ApplyPromocode(int bookingID, String promocode)
    Constructs an ApplyPromocode command with the specified booking ID and promotional code.
  • Method Summary

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

    Methods inherited from class java.lang.Object

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

    • ApplyPromocode

      public ApplyPromocode(int bookingID, String promocode)
      Constructs an ApplyPromocode command with the specified booking ID and promotional code.
      Parameters:
      bookingID - The booking ID of the flight to apply the promocode
      promocode - The promotional code to apply
  • Method Details

    • execute

      public void execute(FlightBookingSystem flightBookingSystem) throws FlightBookingSystemException, IOException
      Executes the ApplyPromocode command within the provided FlightBookingSystem instance. Retrieves the booking with the specified ID, applies the promotional code to its associated flight, and stores the updated data using FlightBookingSystemData.
      Specified by:
      execute in interface Command
      Parameters:
      flightBookingSystem - The FlightBookingSystem instance on which the promocode is to be applied
      Throws:
      FlightBookingSystemException - If there is an issue applying the promocode to the flight
      IOException - If there is an error storing data using FlightBookingSystemData