helper
Class CargoContainer

java.lang.Object
  extended by helper.CargoContainer

public class CargoContainer
extends java.lang.Object

This class encapsulates a cargo container that can hold boxes of stereos and boxes of TV (no other type of cargo). It provides a limited variety of services, such as adding to and modifying the contents of the cargo container.


Constructor Summary
CargoContainer()
          Constructs a default cargo container with the value of boxesOfTVs as 0 and the number of boxesOfStereos as 0.
 
Method Summary
 void addAStereoBox()
          Add the passed value of boxesOfStereos to the cargo container
 void addATVBox()
          Add the passed value of boxesOfTVs to the cargo container
 boolean equals(java.lang.Object otherCargoContainer)
          Checks whether this cargo container is equal to the passed vending machine, where two machines are considered equal if their contents have the same number of boxes of TVs and the same number of boxes of stereos.
 int getBoxesOfStereos()
          Returns the number of boxesOfStereos in the cargo container
 int getBoxesOfTVs()
          Returns the number of boxesOfTVs in the cargo container
 int getTotalValueOfCargoContainer()
          Returns the value of the contents of this cargo container (defined as all the boxes of stereos and boxes of TVs) in dollars
 double getValueOfBoxesOfStereos()
          Returns the value of the boxes of stereos contained in this cargo container in dollars
 double getValueOfBoxesOfTVs()
          Returns the value of the boxes of TVs contained in this cargo container in dollars
 void setBoxesOfStereos(int boxesOfStereos)
          Sets the number of boxes of stereos in this cargo container to be the passed quantity.
 void setBoxesOfTVs(int boxesOfTVs)
          Sets the number of boxes of TVs in this cargo container to be the passed quantity.
 void shouldShowValue(boolean shouldShowValue)
          Sets whether this object, when printed out using its toProperString() method, should shows itself as the monetary value of its contents or as a formatted string that lists the contents of this cargo container.
 java.lang.String toProperString()
          Returns a string representation of this cargo container that is either the monetary value of its contents or a formatted description of the contents of this cargo container (in terms of the number of boxes of stereos and boxes of TVs contained in this cargo container).
 boolean valueEquals(CargoContainer otherCargoContainer)
          Checks whether the value of the contents of this cargo container is equal to the value of the contents of the passed cargo container
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CargoContainer

public CargoContainer()
Constructs a default cargo container with the value of boxesOfTVs as 0 and the number of boxesOfStereos as 0.

Method Detail

addAStereoBox

public void addAStereoBox()
Add the passed value of boxesOfStereos to the cargo container

Throws:
java.lang.Exception - if the number of boxes of stereos is less than zero

addATVBox

public void addATVBox()
Add the passed value of boxesOfTVs to the cargo container

Throws:
java.lang.Exception - if the number of boxes of TVs is less than zero

getBoxesOfTVs

public int getBoxesOfTVs()
Returns the number of boxesOfTVs in the cargo container


setBoxesOfTVs

public void setBoxesOfTVs(int boxesOfTVs)
Sets the number of boxes of TVs in this cargo container to be the passed quantity.

Parameters:
boxesOfTVs - the number of boxes of TVs that should be in this cargo container
Throws:
java.lang.Exception - if the number of boxes of TVs is less than zero

getBoxesOfStereos

public int getBoxesOfStereos()
Returns the number of boxesOfStereos in the cargo container


setBoxesOfStereos

public void setBoxesOfStereos(int boxesOfStereos)
Sets the number of boxes of stereos in this cargo container to be the passed quantity.

Parameters:
boxesOfStereos - the number of boxes of stereos that should be in this cargo container
Throws:
java.lang.Exception - if the passed quantity is less than zero

getValueOfBoxesOfStereos

public double getValueOfBoxesOfStereos()
Returns the value of the boxes of stereos contained in this cargo container in dollars


getValueOfBoxesOfTVs

public double getValueOfBoxesOfTVs()
Returns the value of the boxes of TVs contained in this cargo container in dollars


getTotalValueOfCargoContainer

public int getTotalValueOfCargoContainer()
Returns the value of the contents of this cargo container (defined as all the boxes of stereos and boxes of TVs) in dollars


equals

public boolean equals(java.lang.Object otherCargoContainer)
Checks whether this cargo container is equal to the passed vending machine, where two machines are considered equal if their contents have the same number of boxes of TVs and the same number of boxes of stereos.

Overrides:
equals in class java.lang.Object

shouldShowValue

public void shouldShowValue(boolean shouldShowValue)
Sets whether this object, when printed out using its toProperString() method, should shows itself as the monetary value of its contents or as a formatted string that lists the contents of this cargo container. By default it is set to true (and toProperString displays the monetary value).


valueEquals

public boolean valueEquals(CargoContainer otherCargoContainer)
Checks whether the value of the contents of this cargo container is equal to the value of the contents of the passed cargo container


toProperString

public java.lang.String toProperString()
Returns a string representation of this cargo container that is either the monetary value of its contents or a formatted description of the contents of this cargo container (in terms of the number of boxes of stereos and boxes of TVs contained in this cargo container). Which of these two options is used depends on this objects state with respect to shouldShowValue (see the method shoudShowValue(boolean). The default option is the first one.