Class IceCreamStation

java.lang.Object
  extended by IceCreamStation

public class IceCreamStation
extends Object

This class represents ice cream station objects. An ice cream station buys cones and ice cream to sell ice cream cones. It also monitors how much ice cream, cones, and cash it has left, as well as how many ice cream cones it has sold.

Version:
2.0 - 22 February 2008 (incorporates guards)
Author:
JP Vergara

Constructor Summary
IceCreamStation()
          Class Constructor.
IceCreamStation(double startCash)
          Class Constructor with starting cash parameter.
 
Method Summary
 void buyCones(int numBoxes)
          Buys one or more boxes of cones.
 void buyIceCream(double pints)
          Buys some pints of ice-cream.
 double getCashOnHand()
          Returns the cash on hand in the station.
 int getConesLeft()
          Returns the cones left in the station.
 double getIceCreamLeft()
          Returns the amount ice cream (in pints) left in the station.
 int getNumIceCreamConesSold()
          Returns the number of ice cream cones sold.
 void sellIceCreamCones(int numCones, double unitPrice)
          Sells one or more ice cream cones at a given price.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IceCreamStation

public IceCreamStation()
Class Constructor. Intializes the variables in the class. An IceCreamStation object starts off with $100.00, no cones and no ice cream


IceCreamStation

public IceCreamStation(double startCash)
Class Constructor with starting cash parameter. Intializes the variables in the class. An IceCreamStation object starts off with no cones and no ice cream, and the cash amount indicated.

Parameters:
startCash - startup cash
Method Detail

buyCones

public void buyCones(int numBoxes)
Buys one or more boxes of cones. Each box costs $2.50 and contains 10 cones. An error message is printed out if there isn't enough cash for the purchase.

Parameters:
numBoxes - number of boxes to be bought

buyIceCream

public void buyIceCream(double pints)
Buys some pints of ice-cream. Each pint costs $3.25. An error message is printed out if there isn't enough cash for the purchase.

Parameters:
pints - pints to be bought

getCashOnHand

public double getCashOnHand()
Returns the cash on hand in the station.

Returns:
cash on hand in dollars

getConesLeft

public int getConesLeft()
Returns the cones left in the station.

Returns:
number of cones left

getIceCreamLeft

public double getIceCreamLeft()
Returns the amount ice cream (in pints) left in the station.

Returns:
number of pints left

getNumIceCreamConesSold

public int getNumIceCreamConesSold()
Returns the number of ice cream cones sold.

Returns:
number of ice cream cones sold

sellIceCreamCones

public void sellIceCreamCones(int numCones,
                              double unitPrice)
Sells one or more ice cream cones at a given price. An ice cream cone requires a single cone (of course!) and 1/4 of a pint of ice cream. An error message is printed out if there aren't enough ingredients for the sale.

Parameters:
numCones - number of cones to be sold
unitPrice - price of each ice cream cone