Class PackageDeliveryControl

java.lang.Object
cmpt213.assignment4.packagedeliveries.client.control.PackageDeliveryControl

public class PackageDeliveryControl extends Object
This class creates a PackageDeliveryControl object which manages data from the server. Data is passed to the UI from this class.
  • Field Details

  • Constructor Details

    • PackageDeliveryControl

      public PackageDeliveryControl(ActionListener al)
      Constructs a PackageDeliveryControl Object. Initializes class fields and also loads in any data from the JSON list.
      Parameters:
      al - The action listener of the parent class, used to help refresh screen.
  • Method Details

    • adjustPackage

      public void adjustPackage(PackageBase pkg, int option, boolean newDeliveryStatus)
      Helper method for adjusting a given Package. Will either remove package or change its delivery state.
      Parameters:
      pkg - The package to be adjusted.
      option - Which adjustment method is selected, based on constants from this class.
      newDeliveryStatus - The new delivery status of package, false if option is to remove.
    • createPackage

      public void createPackage(String name, String notes, double price, double weight, LocalDateTime date, String extraField, PackageFactory.PackageType type)
      Method that creates a new Package using the PackageFactory class. Update lists after package creation.
      Parameters:
      name - Name of the package.
      notes - Any notes for the package.
      price - Price of the package.
      weight - Weight of the package.
      date - Expected Delivery Date of the package.
      extraField - Extra field of the package, in String form already.
      type - Subclass type of the package, uses PackageFactory.PackageType.
    • getAListOfPackages

      public ArrayList<PackageBase> getAListOfPackages(Util.SCREEN_STATE currentState)
      Helper method that allows the UI to access the lists.
      Parameters:
      currentState - Current state of UI tells method which list to return.
      Returns:
      Returns an ArrayList based on the current state.
    • saveClientData

      public void saveClientData()
      Helper method that is called whenever the GUI exits. Sends all data to server for saving.