Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition
by Paul J. Deitel - Deitel & Associates, Inc., Harvey M. Deitel - Deitel & Associates, Inc.
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access