ATM Case Study Code
J.1 ATM Case Study Implementation
This appendix contains the complete working implementation of the ATM system that we designed in the “Software Engineering Case Study” sections found at the ends of
Chapters 1–8 and 10. The implementation comprises 670 lines of Java code. We consider the classes in the order in which we identified them in Section 3.10:
•
ATM
•
Screen
•
Keypad
•
CashDispenser
•
DepositSlot
•
Account
•
BankDatabase
•
Transaction
•
BalanceInquiry
•
Withdrawal
•
Deposit
We apply the guidelines discussed in Section 8.19 and Section 10.9 to code these classes based on how we modeled them in the UML class diagrams of Fig. 10.21 and Fig. 10.22.
To develop the bodies of class methods, we refer to the activity diagrams presented in
Section 5.11 and the communication and sequence diagrams presented in Section 7.14.
Note that our ATM design does not specify all the program logic and may not specify all the attributes and operations required to complete the ATM implementation. This is a normal part of the object-oriented design process. As we implement the system, we com-
J.2 Class ATM
1465
plete the program logic and add attributes and behaviors as necessary to construct the
ATM system specified by the requirements document in Section 2.9.
We conclude the discussion by presenting a Java application (ATMCaseStudy) that starts the ATM and puts the other classes in the system in use. Recall that we are developing a first version of the ATM system that runs on a personal computer and uses the computer’s keyboard and monitor to approximate the ATM’s keypad and screen. We also only simulate the actions of the ATM’s cash dispenser and deposit slot. We attempt to implement the system, however, so that real hardware versions of these devices could be integrated without significant changes in the code.
J.2 Class ATM
Class ATM (Fig. J.1)