Class BoxedItem

java.lang.Object
com.zybooks.dsaj.design.BoxedItem
All Implemented Interfaces:
Sellable, Transportable

public class BoxedItem extends Object implements Sellable, Transportable
Class for objects that can be sold, packed, and shipped.
  • Constructor Details

    • BoxedItem

      public BoxedItem(String desc, int p, int w, boolean h)
      Constructor
      Parameters:
      desc - a description of the item
      p - the price of the item in cents
      w - the weight of the item in grams
      h - true if object is hazardous
  • Method Details

    • description

      public String description()
      Returns a description of the item.
      Specified by:
      description in interface Sellable
      Returns:
      a description of the item
    • listPrice

      public int listPrice()
      Returns the list price of the item in cents.
      Specified by:
      listPrice in interface Sellable
      Returns:
      the list price of the item in cents
    • lowestPrice

      public int lowestPrice()
      Returns the lowest price, in cents, we will accept.
      Specified by:
      lowestPrice in interface Sellable
      Returns:
      the lowest price, in cents, we will accept
    • weight

      public int weight()
      Returns the weight of the item.
      Specified by:
      weight in interface Transportable
      Returns:
      the weight of the item
    • isHazardous

      public boolean isHazardous()
      Returns whether the item is hazardous.
      Specified by:
      isHazardous in interface Transportable
      Returns:
      true if the item is hazardous, else false
    • insuredValue

      public int insuredValue()
      Returns the insured value of the item.
      Returns:
      the insured value of the item
    • setBox

      public void setBox(int h, int w, int d)
      Sets the dimensions of the item's box.
      Parameters:
      h - the height of the box
      w - the width of the box
      d - the depth of the box