Atm Simulator
Atm Simulator
Create a specification
Design
behavior
implementation.
ATM user interface (sort of)
subsystem.
For this phase, we will use a dummy Bank. It approves
all requests.
ATM Use Case: withdraw (1)
Description: Customer withdraws money from account
Actors: Bank customer with ATM card
Steps:
1. ATM machine displays greeting.
2. Customer inserts card.
3. ATM reads card and prompts customer for PIN.
4. Customer enters PIN.
5. ATM contacts Bank to verify customer's PIN.
6. Bank verifies PIN.
7. ATM prompts customer for transaction type.
8. Customer chooses withdraw.
ATM Use Case: withdraw (2)
9. ATM asks customer to enter amount to withdraw.
10. Customer enters amount.
11. ATM verifies it has bills to provide this amount.
12. ATM contacts Bank to verify customer can withdraw
the requested amount.
13. Bank verifies withdraw and debits customer's acct.
14. ATM dispenses amount and prompts customer to take
money.
15. Customer takes money.
ATM Use Case: withdraw (3)
16. ATM prints receipt and prompts customer to take it.
17. Customer take receipt.
18. ATM asks customer if he wants another transaction.
19. Customer selects "no" option.
20. ATM returns customer's card.
21. Customer takes card.
ATM Use Case: withdraw (4)
Extensions and Alternatives:
Scenario: step 3, ATM cannot read valid acct number from
ATM card.
3a. ATM prints message describing problem.
3b. execute steps 20-21 of main course.
Scenario: step 6. Bank indicates PIN is incorrect.
6a. if count of failed PIN attempts is < 3, goto step 3.
Otherwise, execute steps 20-21 of main course.
Scenario: step 11, customer's entry is not a number or
ATM cannot dispense the requested amount.
11a. Display message describing problem.
11b. Return to step 9.
ATM Use Case: withdraw (5)
Extensions and Alternatives:
Scenario: at any time after authentication the customer
presses CANCEL button.
__a. Return customer's card and prompt him to take it.
Extension: a customer may have more than one account.
Enable customer to choose account for withdrawal.
common task.
responsibilities.
Structure: identify classes
Nouns in the requirements document.
operations
Called an elided diagram
Solid line that connects two classes represents
an association
numbers near end of each line are multiplicity values
Class Diagram with Association
Attributes and methods are omitted ("elided")
In early design phase, concentrate on identifying
Messages
Stack LinkedList
push addFirst
pop addLast
isEmpty addAfter
removeFirst
removeLast
delete
isEmpty
Diagram for ATM with Withdrawal
However, in our implementation we will separate UI from ATM functionality
(deposit, withdraw, etc).
dispenser, etc.
Create a Java interface to define public methods.
<<interface>>
ATMInterface <<ATM Logic Engine>>
displayMessage ATMsim
atmUI: ATMInterface
ATM( atmUI )
deposit( )
ATM UI
withdraw( )
balanceInquiry( )
ATM with Separate User Interface
Benefits of using an interface:
you can change the actual user interface without
dispenser, etc.
Create a Java interface to define public methods.
<<interface>>
ATMInterface <<ATM Logic Engine>>
displayMessage
ATM
atmUI: ATMInterface
ATM( atmUI )
Keypad deposit( )
ATM GUI
withdraw( )
Screen balanceInquiry( )
Card Slot
Identify Class Responsibilities
What are the main responsibilities of each class?
responsibilities are usually activities or actions
eliminated
Example:
project simultaneously
helps to limit complexity and enforce good design
Identifying Class Attributes
Identifying attributes
Look for descriptive nouns and phrases in the
requirements document
Eliminate some nouns:
[Invalid/unreadable card]
Verify ATM card
Transaction
Fail 3 times or Cancel
Loop
End Session /
Return ATM card
Transaction Loop
UML state chart diagram for transaction loop
Transaction Loop
Display Transactions Menu