    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.

##

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

##

CashDispenser(Log)
  Constructor

##

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

##

log

     private Log log

  Log into which cash amounts dispensed will be recorded

cashOnHand

     private Money cashOnHand

  Current cash on hand

##

CashDispenser

     public CashDispenser(Log log)

  Constructor

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

##

setInitialCash

     public void setInitialCash(Money initialCash)

  Set the amount of cash initially on hand

  Parameters:
    initialCash - the amount of money in the dispenser

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

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