java.lang.Object
cmpt213.assignment4.packagedeliveries.client.model.PackageBase
All Implemented Interfaces:
Package, Comparable<PackageBase>
Direct Known Subclasses:
Book, Electronic, Perishable

public abstract class PackageBase extends Object implements Package
Abstract package base class that is modelled after a package; stores name, notes, price, weight, date, and delivery status. Must be implemented as: Book, Perishable, or Electronic. Implements the Package Interface.
  • Field Details

    • dateFormat

      protected static final DateTimeFormatter dateFormat
    • name

      protected final String name
    • notes

      protected final String notes
    • price

      protected final double price
    • weight

      protected final double weight
    • expectedDeliveryDate

      protected final LocalDateTime expectedDeliveryDate
    • isDelivered

      protected boolean isDelivered
  • Constructor Details

    • PackageBase

      public PackageBase(String name, String notes, double price, double weight, LocalDateTime expectedDeliveryDate)
      Constructor for class, creates an object modelled as a package with its respective fields.
      Parameters:
      name - The name of the package, cannot be empty.
      notes - Any notes for the package, can be empty.
      price - The price (in CAD) of the package, cannot be negative.
      weight - The weight (in kg) of the package, cannot be negative.
      expectedDeliveryDate - The date of the package (Year, Month, Day, Hour, Minute), in 24-hour format.
  • Method Details

    • compareTo

      public int compareTo(PackageBase p)
      Sorts arraylist of package base items based on delivery date. Order: oldest to newest. Implementation of Package.compareTo(PackageBase)
      Specified by:
      compareTo in interface Comparable<PackageBase>
      Specified by:
      compareTo in interface Package
      Parameters:
      p - the object to be compared.
      Returns:
      An integer, positive if date is before current time, negative if after.
    • isDelivered

      public boolean isDelivered()
      Gets the package's delivery status; returns false if not delivered, true if delivered. Implementation of Package.isDelivered()
      Specified by:
      isDelivered in interface Package
      Returns:
      A boolean value (true or false)
    • setDeliveryStatus

      public void setDeliveryStatus(boolean newStatus)
      Changes a package's delivery status; either true or false. Implementation of Package.setDeliveryStatus(boolean)
      Specified by:
      setDeliveryStatus in interface Package
      Parameters:
      newStatus - The new status of the package, boolean value.
    • getExpectedDeliveryDate

      public LocalDateTime getExpectedDeliveryDate()
      Gets the delivery date of the package as a LocalDateTime object. Implementation of Package.getExpectedDeliveryDate()
      Specified by:
      getExpectedDeliveryDate in interface Package
      Returns:
      A LocalDateTime object with the date information.
    • getName

      public String getName()
      Gets the name of the package. Implementation of Package.getName()
      Specified by:
      getName in interface Package
      Returns:
      A String that holds the name.
    • getNotes

      public String getNotes()
      Gets the notes of the package. Implementation of Package.getNotes()
      Specified by:
      getNotes in interface Package
      Returns:
      A String that holds the notes.
    • getPrice

      public double getPrice()
      Gets the price of the package. Implementation of Package.getPrice()
      Specified by:
      getPrice in interface Package
      Returns:
      A double that holds the price.
    • getWeight

      public double getWeight()
      Gets the weight of the package. Implementation of Package.getWeight()
      Specified by:
      getWeight in interface Package
      Returns:
      A double that holds the weight.