All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class atm.physical.CashDispenser

java.lang.Object
   |
   +----atm.physical.CashDispenser

public class CashDispenser
extends Object
Manager for the ATM's cash dispenser. In a real ATM, this would manage a physical device; in this simulation, it uses classes in package simulation to simulate the device.


Variable Index

 o cashOnHand
Current cash on hand
 o log
Log into which cash amounts dispensed will be recorded

Constructor Index

 o CashDispenser(Log)
Constructor

Method Index

 o checkCashOnHand(Money)
See if there is enough cash on hand to satisfy a request
 o dispenseCash(Money)
Dispense cash to a customer
 o setInitialCash(Money)
Set the amount of cash initially on hand

Variables

 o log
 private Log log
Log into which cash amounts dispensed will be recorded

 o cashOnHand
 private Money cashOnHand
Current cash on hand

Constructors

 o CashDispenser
 public CashDispenser(Log log)
Constructor

Parameters:
log - the log in which to record dispensing cash

Methods

 o setInitialCash
 public void setInitialCash(Money initialCash)
Set the amount of cash initially on hand

Parameters:
initialCash - the amount of money in the dispenser
 o checkCashOnHand
 public boolean checkCashOnHand(Money amount)
See if there is enough cash on hand to satisfy a request

Parameters:
amount - the amount of cash the customer wants
Returns:
true if at least this amount of money is available
 o dispenseCash
 public void dispenseCash(Money amount)
Dispense cash to a customer

Parameters:
amount - the amount of cash to dispense Precondition: amount is <= cash on hand

All Packages  Class Hierarchy  This Package  Previous  Next  Index