helper
Class VendingMachine

java.lang.Object
  extended by helper.VendingMachine

public class VendingMachine
extends java.lang.Object

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

VendingMachine

public VendingMachine()
Constructs a default vending machine with the value of cansOfPop as 0 and the number of bagsOfChips as 0.

Method Detail

addABagOfChips

public void addABagOfChips()
Add one bag of chips to the vending machine


addACanOfPop

public void addACanOfPop()
Add one can of pop to the vending machine


getCansOfPop

public int getCansOfPop()
Returns the number of cansOfPop in the vending machine


getPriceOfPop

public double getPriceOfPop()
Returns the price of one can of pop


setCansOfPop

public void setCansOfPop(int cansOfPop)
Sets the number of cans of pop in this vending machine to be the passed quantity.

Parameters:
cansOfPop - the number of cans of pop that should be in this vending machine
Throws:
java.lang.Exception - if the number of cans of pop is less than zero

getBagsOfChips

public int getBagsOfChips()
Returns the number of bagsOfChips in the vending machine


gerPriceOfChips

public double gerPriceOfChips()
Returns the price of one bag of chips


setBagsOfChips

public void setBagsOfChips(int bagsOfChips)
Sets the number of bags of chips in this vending machine to be the passed quantity.

Parameters:
bagsOfChips - the number of bags of chips that should be in this vending machine
Throws:
java.lang.Exception - if the passed quantity is less than zero

getValueOfBagsOfChips

public double getValueOfBagsOfChips()
Returns the value of the bags of chips contained in this vending machine in dollars


getValueOfCansOfPop

public double getValueOfCansOfPop()
Returns the value of the cans of pop contained in this vending machine in dollars


getTotalValueOfVendingMachine

public 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


equals

public 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.

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 vending machine.


valueEquals

public 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


toProperString

public 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). 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.