Skip to main content

ATM withdrawal sequence diagram

Short answer

Collaborating objects are Customer, ATM, Card, Bank, Account. Key methods include insertCard, getAccountNumber, encrypt, verify, withdraw, dispenseCash. The ATM encrypts PIN and account number, sends to Bank for verification; if valid, prompts for amount and withdraws from Account before dispensing cash.

Find all the Methods and collaborating objects for case study given below. Based on the methods and objects identified create a sequence diagram for the following collaboration. A customer wants to draw money from his bank account. He enters his card into an ATM (automated teller machine). The ATM machine prompts "Enter PIN". The customer enters his PIN. The ATM (internally) retrieves the bank account number from the card. The ATM encrypts the PIN and the account number and sends it over to the bank. The bank verifies the encrypted Account and PIN number. If the PIN number is correct, the ATM displays "Enter amount", draws money from the bank account and pays out the amount.

Collaborating objects (classes)

Customer (actor), ATM (user interface / controller), Card, Bank (verification and transaction server), Account.

Methods identified

ObjectMethods
CustomerinsertCard(), enterPIN(), enterAmount()
ATMpromptPIN(), readAccountNumber(), encrypt(), promptAmount(), dispenseCash()
CardgetAccountNumber()
Bankverify(encAcc, encPIN)
Accountwithdraw(amount), getBalance()

Sequence diagram

 Customer      :ATM          :Card        :Bank        :Account
    |            |             |            |             |
    | insertCard |             |            |             |
    |----------->|             |            |             |
    |"Enter PIN" |             |            |             |
    |<-----------|             |            |             |
    | enterPIN   |             |            |             |
    |----------->|             |            |             |
    |            | getAccountNumber()       |             |
    |            |------------>|            |             |
    |            |<- - - - - - |            |             |
    |            |--.          |            |             |
    |            |  | encrypt(PIN, accNo)    |             |
    |            |<-'          |            |             |
    |            | verify(encAcc, encPIN)   |             |
    |            |------------------------->|             |
    |            |<- - - valid / invalid - -|             |
    |  [alt: PIN valid]                                    |
    |"Enter amount"            |            |             |
    |<-----------|             |            |             |
    | enterAmount|             |            |             |
    |----------->|             |            |             |
    |            | withdraw(amount)         |             |
    |            |------------------------->|             |
    |            |             |            | withdraw()  |
    |            |             |            |------------>|
    |            |             |            |<- - - - - - |
    |            |<- - - - - - OK - - - - - |             |
    |   cash     | dispenseCash()           |             |
    |<-----------|             |            |             |
    |  [else: PIN invalid] ATM shows an error / retries    |

Explanation

  1. The customer inserts the card and the ATM prompts "Enter PIN".
  2. After the PIN is entered, the ATM gets the account number from the card.
  3. The ATM encrypts the PIN and account number and sends them to the bank.
  4. The bank verifies them. Alternative (alt fragment): if they are invalid, the bank returns "invalid" and the ATM shows an error or lets the customer retry.
  5. If the PIN is correct, the ATM asks for the amount, the bank withdraws it from the Account (after checking the balance), and the ATM dispenses the cash.

✓ Answer checked by Claude Sonnet 5.5

All Object Oriented Analysis and Design chapter 2 questions →