Class EggTrader

java.lang.Object
  extended by EggTrader

public class EggTrader
extends Object

Class EggTrader simulates a person buying and selling eggs.

Version:
02/18/2008
Author:
YT Sun

Constructor Summary
EggTrader()
          Constructor for objects of class EggTrader.
 
Method Summary
 void buyOneDozen(double pricePerDozen)
          Method buyOneDozen buys a dozen eggs.
 double getCash()
          Method getCash returns the current balance.
 int getEggCount()
          Method getEggCount returns the current egg count.
 void sellEggs(int numEggs, double unitPrice)
          Method sellEggs sells eggs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EggTrader

public EggTrader()
Constructor for objects of class EggTrader. eggCount is initialized to 0, cash is initialized to 10.00.

Method Detail

buyOneDozen

public void buyOneDozen(double pricePerDozen)
Method buyOneDozen buys a dozen eggs. Eggs cannot be purchased without sufficient funds.

Parameters:
pricePerDozen - price per 12 eggs

getCash

public double getCash()
Method getCash returns the current balance.

Returns:
current cash balance

getEggCount

public int getEggCount()
Method getEggCount returns the current egg count.

Returns:
current egg count

sellEggs

public void sellEggs(int numEggs,
                     double unitPrice)
Method sellEggs sells eggs. Eggs cannot be sold without sufficient egg reserves.

Parameters:
numEggs - eggs being sold
unitPrice - selling price per egg