J.5. Class CashDispenser

Class CashDispenser (Fig. J.4) represents the cash dispenser of the ATM. Line 5 declares constant INITIAL_COUNT, which indicates the initial count of bills in the cash dispenser when the ATM starts (i.e., 500). Line 6 implements attribute billCount (modeled in Fig. 11.20), which keeps track of the number of bills remaining in the CashDispenser at any time. The constructor (lines 9–11) sets billCount to the initial count. [Note: We assume that the process of adding more bills to the CashDispenser and updating the billCount occur outside the ATM system.] Class CashDispenser has two Public methods—DispenseCash (lines 14–18) and IsSufficientCashAvailable (lines 21–31). The class trusts that a client (i.e., Withdrawal) calls ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.