0% found this document useful (0 votes)
132 views36 pages

Atm Simulator

Here are the main responsibilities of some key classes: - ATMInterface - Defines methods for displaying messages, accepting user input, reading/returning cards, printing receipts, dispensing cash. Acts as the interface between UI and logic classes. - ATM - Encapsulates core ATM functionality like depositing, withdrawing, checking balances. Coordinates with Bank class. - Bank - Manages customer accounts and processes requests from ATM like verifying funds, debiting/crediting amounts. - Customer - Represents a bank customer with attributes like name, PIN, account(s). - Transaction - Models individual transactions like deposits and withdrawals with amounts, dates, etc. - Screen,

Uploaded by

Hari Viswanadh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views36 pages

Atm Simulator

Here are the main responsibilities of some key classes: - ATMInterface - Defines methods for displaying messages, accepting user input, reading/returning cards, printing receipts, dispensing cash. Acts as the interface between UI and logic classes. - ATM - Encapsulates core ATM functionality like depositing, withdrawing, checking balances. Coordinates with Bank class. - Bank - Manages customer accounts and processes requests from ATM like verifying funds, debiting/crediting amounts. - Customer - Represents a bank customer with attributes like name, PIN, account(s). - Transaction - Models individual transactions like deposits and withdrawals with amounts, dates, etc. - Screen,

Uploaded by

Hari Viswanadh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

ATM Simulator

Software Life Cycle


 Elicit requirements
 describe use cases

 Create a specification

 Design

 structure (classes and their relations)

 behavior

 state What about testing and documentation?


 Implement
Why aren't they listed as steps in the life
cycle?
 Deploy

 Maintain & Enhance


Unified Software Process
 Iterative and Incremental
 Perform multiple iterations

 Incrementally (in each iteration) add functionality

 Start with most important use cases or requirements


ATM Simulator
 Design and implement an ATM Simulator that simulates
the functions of a real ATM.
 The ATM will support PIN authentication, balance

inquiry, and withdrawal. If time permits, we will add


deposit and transfers.
Goals
 Practice software development methodology using UML,

interfaces, and inheritance.


 Use O-O design to limit the complexity of

implementation.
ATM user interface (sort of)

Our Simulator will have more buttons than this.


ATM main menu (sort of)

Our Simulator may have more menu options than this.


ATM Phase 1
 Develop requirements for an ATM with withdrawal and
balance inquiry.
 Implement a simple ATM engine and console interface.

 Determine what public methods (interface) are needed

for an ATM U.I.


 Determine what services are needed from the Bank

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.

Issue: if customer presses CANCEL should ATM return


card or return to option's menu?
Issue: after 3 failed PIN attempts should ATM notify Bank
for security reasons? I.e., temporarily lock-out this ATM
card.
ATM Use Case: balance inquiry (1)
Description: Customer inquires his account balance
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 balance inquiry.
ATM Use Case: balance inquiry (2)
To be completed.
ATM Use Case: deposit (1)
Description: Customer deposits funds (cash or checks) in
account using a deposit envelop
Actors: Bank customer with ATM card and funds
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 deposit.
ATM Use Case: deposit (2)
To be completed.
Use Case Factoring and Diagram
 Factor out common behavior from the use cases.
 Steps 1 - 7 are the same in all use cases.

 Displaying menu and choosing an option is another

common task.

 Draw a Use Case Diagram.


 Helpful for visually actors and components.

 Free UML editor: ArgoUML (argouml.tigris.org)


Specification
 Use cases help you identify what a system should do.
 A software specification document clarifies what the

program should do.


 This is usually part of a software contract.

 Can be formal or informal, but must be written.

 Specification will help identify classes and

responsibilities.
Structure: identify classes
Nouns in the requirements document.

Nouns and noun phrases in the requirements document


bank money / funds account number
ATM screen PIN
user keypad bank database
customer cash dispenser balance inquiry
transaction $20 bill / cash withdrawal
account deposit slot deposit
balance deposit envelope
Source: Dietel & Dietel, Java, How to Program.
Modeling Classes
 UML class diagrams
 Allows suppression of class attributes and

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

classes and responsibilities first.


 numbers near end of each line are multiplicity
Modeling Classes
 UML class diagrams
 Solid diamonds attached to association lines

indicate a composition relationship


 Hollow diamonds indicate aggregation – a

weaker form of composition


Class diagram for ATM U.I.
 Association and Composition
 Used when one object "owns" or controls another

 Solid diamonds indicate composition relationship: the

ATM is composed of these parts; the parts do not


exist without the whole (ATM)

Source: Dietel & Dietel, Java, How to Program


Class diagram for ATM U.I.
 Association and Composition
 Hollow (open) diamonds indicate association

relationship: the whole possesses these parts, but


the parts can exist without the whole.
 Examples: a Stack has a LinkedList, a Mailbox has

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).

Source: Dietel & Dietel, Java, How to Program


ATM with Separate User Interface
 Separate ATM user interface from the class(es) that
provide ATM functionality.
 user interface is screen, keypad, card slot, money

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

changing any other parts of the system


 Example:

a class implementing ATMInterface is responsible for


displaying messages, accepting input from keypad,
reading ATM card, returning ATM card, printing
receipts, and dispensing cash
 for a GUI interface, we may decide to divide these

responsibilities into separate classes


 one main class, called a Façade, acts as interface between
ATM Engine and the various component classes.
ATM with Separate User Interface
 Separate ATM user interface from the class(es) that
provide ATM functionality.
 user interface is screen, keypad, card slot, money

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

 if a class doesn't have any responsibilities, it can be

eliminated
 Example:

 initially write a console-based U.I.

Later we will write a GUI for ATM.


 multiple programmers can work on different parts of

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:

 (1) redundant, (2) abstract, (3) describe instances,


(4) outside the problem boundary (domain)
 Create attributes and assign them to classes
Possible Attributes for ATM System
First Iteration
 Ignore the Bank and Account components.
 No GUI interface.

 Design a basic ATM engine, ATM interface (Java

interface), and console-based UI.


 Handle only a few transactions: withdraw, fast cash.
Design: use a state chart
 A state chart diagram can help understand behavior.
Start

Wait for an ATM user

[Invalid/unreadable card]
Verify ATM card

Verify PIN Code


Fail < 3 times

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

"Deposit" action "Inquiry" action "Withdraw" action

Deposit dialog Show Balance Withdraw dialog

OK cancel OK END cancel OK

error get deposit verify input and fail


envelop Exit available balance
OK OK
Second Iteration (due Tues 6/9/2005)
 implement the ATMInterface.java as a console interface.
 write an ATM simulator that does this:

 read ATM card and PIN

 display transaction menu

 handle withdraw, fast cash, and balance inquiry

 use the ATMInterface for all I/O

 Design a Transaction class to encapsulate transactions.

You might also like