|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthelper.CargoContainer
public class CargoContainer
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. |
|
CargoContainer(int boxesOfStereos,
int boxesOfTVs)
Constructs a cargo container with the passed value of boxesOfTVs and the passed value of boxesOfStereos. |
Method Summary | |
---|---|
void |
addBoxesOfStereos(int boxesOfStereos)
Add the passed value of boxesOfStereos to the cargo container |
void |
addBoxesOfTVs(int boxesOfTVs)
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 |
double |
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 |
mergeContents(CargoContainer otherCargoContainer)
Adds the contents of the passed cargo container to the contents of this cargo container. |
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 |
---|
public CargoContainer()
public CargoContainer(int boxesOfStereos, int boxesOfTVs)
java.lang.Exception
- if the number of boxes of stereos or the number of boxes of TVs is
less than zeroMethod Detail |
---|
public void addBoxesOfStereos(int boxesOfStereos)
java.lang.Exception
- if the number of boxes of stereos is less than zeropublic void addBoxesOfTVs(int boxesOfTVs)
java.lang.Exception
- if the number of boxes of TVs is less than zeropublic int getBoxesOfTVs()
public void setBoxesOfTVs(int boxesOfTVs)
boxesOfTVs
- the number of boxes of TVs that should be in this cargo
container
java.lang.Exception
- if the number of boxes of TVs is less than zeropublic int getBoxesOfStereos()
public void setBoxesOfStereos(int boxesOfStereos)
boxesOfStereos
- the number of boxes of stereos that should be in this cargo
container
java.lang.Exception
- if the passed quantity is less than zeropublic double getValueOfBoxesOfStereos()
public double getValueOfBoxesOfTVs()
public double getTotalValueOfCargoContainer()
public void mergeContents(CargoContainer otherCargoContainer)
public boolean equals(java.lang.Object otherCargoContainer)
equals
in class java.lang.Object
public void shouldShowValue(boolean shouldShowValue)
public boolean valueEquals(CargoContainer otherCargoContainer)
public java.lang.String toProperString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |