Class BoxedItem2

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

public class BoxedItem2 extends Object implements Insurable
Class for objects that can be sold, packed, and shipped.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BoxedItem2(String desc, int p, int w, boolean h)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a description of the item.
    int
    Returns the insured value of the item, in cents.
    boolean
    Returns whether the item is hazardous.
    int
    Returns the list price of the item, in cents.
    int
    Returns the lowest price, in cents, we will accept.
    void
    setBox(int h, int w, int d)
    Sets the dimensions of the item's box, in centimeters.
    int
    Returns the weight of the item, in grams.

    Methods inherited from class java.lang.Object

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

    • BoxedItem2

      public BoxedItem2(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, in grams.
      Specified by:
      weight in interface Transportable
      Returns:
      the weight of the item, in grams
    • 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, in cents.
      Specified by:
      insuredValue in interface Insurable
      Returns:
      the insured value of the item, in cents
    • setBox

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