Class PackageDeliveryControl
java.lang.Object
cmpt213.assignment4.packagedeliveries.client.control.PackageDeliveryControl
This class creates a PackageDeliveryControl object which manages data from the server.
Data is passed to the UI from this class.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a PackageDeliveryControl Object. -
Method Summary
Modifier and TypeMethodDescriptionvoidadjustPackage(PackageBase pkg, int option, boolean newDeliveryStatus) Helper method for adjusting a given Package.voidcreatePackage(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.getAListOfPackages(Util.SCREEN_STATE currentState) Helper method that allows the UI to access the lists.voidHelper method that is called whenever the GUI exits.
-
Field Details
-
ADD
public static final int ADD- See Also:
-
REMOVE
public static final int REMOVE- See Also:
-
DELIVERY_STATUS
public static final int DELIVERY_STATUS- See Also:
-
GET_ALL
- See Also:
-
GET_OVERDUE
- See Also:
-
GET_UPCOMING
- See Also:
-
POST_ADD_PACKAGE
- See Also:
-
POST_REMOVE_PACKAGE
- See Also:
-
POST_MARK_DELIVERED
- See Also:
-
EXIT
- See Also:
-
masterListOfPackages
-
-
Constructor Details
-
PackageDeliveryControl
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
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
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.
-