|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthelper.VendingMachine
public class VendingMachine
This class encapsulates a vending bank that can hold bags of chips and cans of pop (no other type of food). It provides a limited variety of services, such as adding to and modifying the contents of the vending machine.
Constructor Summary | |
---|---|
VendingMachine()
Constructs a default vending machine with the value of cansOfPop as 0 and the number of bagsOfChips as 0. |
Method Summary | |
---|---|
void |
addABagOfChips()
Add one bag of chips to the vending machine |
void |
addACanOfPop()
Add one can of pop to the vending machine |
boolean |
equals(java.lang.Object otherVendingmachine)
Checks whether this vending machine is equal to the passed vending machine, where two machines are considered equal if their contents have the same number of cans of pop and the same number of bags of chips. |
double |
gerPriceOfChips()
Returns the price of one bag of chips |
int |
getBagsOfChips()
Returns the number of bagsOfChips in the vending machine |
int |
getCansOfPop()
Returns the number of cansOfPop in the vending machine |
double |
getPriceOfPop()
Returns the price of one can of pop |
double |
getTotalValueOfVendingMachine()
Returns the value of the contents of this vending machine (defined as all the bags of chips and cans of pop) in dollars |
double |
getValueOfBagsOfChips()
Returns the value of the bags of chips contained in this vending machine in dollars |
double |
getValueOfCansOfPop()
Returns the value of the cans of pop contained in this vending machine in dollars |
void |
setBagsOfChips(int bagsOfChips)
Sets the number of bags of chips in this vending machine to be the passed quantity. |
void |
setCansOfPop(int cansOfPop)
Sets the number of cans of pop in this vending machine 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 vending machine. |
java.lang.String |
toProperString()
Returns a string representation of this vending machine that is either the monetary value of its contents or a formatted description of the contents of this vending machine (in terms of the number of bags of chips and cans of pop contained in this vending machine). |
boolean |
valueEquals(VendingMachine otherVendingmachine)
Checks whether the value of the contents of this vending machine is equal to the value of the contents of the passed vending machine |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VendingMachine()
Method Detail |
---|
public void addABagOfChips()
public void addACanOfPop()
public int getCansOfPop()
public double getPriceOfPop()
public void setCansOfPop(int cansOfPop)
cansOfPop
- the number of cans of pop that should be in this vending
machine
java.lang.Exception
- if the number of cans of pop is less than zeropublic int getBagsOfChips()
public double gerPriceOfChips()
public void setBagsOfChips(int bagsOfChips)
bagsOfChips
- the number of bags of chips that should be in this vending
machine
java.lang.Exception
- if the passed quantity is less than zeropublic double getValueOfBagsOfChips()
public double getValueOfCansOfPop()
public double getTotalValueOfVendingMachine()
public boolean equals(java.lang.Object otherVendingmachine)
equals
in class java.lang.Object
public void shouldShowValue(boolean shouldShowValue)
public boolean valueEquals(VendingMachine otherVendingmachine)
public java.lang.String toProperString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |