---
title: "ATM withdrawal sequence diagram"
subject: "Object Oriented Analysis and Design"
chapter: 2
key: "semester_6/object_oriented_analysis_and_design:atm-withdrawal-sequence-diagram"
source: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/atm-withdrawal-sequence-diagram
site: BCT Engineering
---

# ATM withdrawal sequence diagram

Object Oriented Analysis and Design · Chapter 2: Object Oriented Analysis

- Asked in: 2071 Magh, 7 marks
- Video: [Sequence Diagram for ATM Cash Withdrawal | StarUML](https://www.youtube.com/watch?v=W_GvrkrnXQ4) — Dr.K. Sutha
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/atm-withdrawal-sequence-diagram
- Whole chapter: https://www.bctengineer.com/md/semester_6/object_oriented_analysis_and_design/chapter-2

## Question

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.

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

## Answer

#### Collaborating objects (classes)
`Customer` (actor), `ATM` (user interface / controller), `Card`, `Bank` (verification and transaction server), `Account`.

#### Methods identified
| Object | Methods |
|---|---|
| Customer | insertCard(), enterPIN(), enterAmount() |
| ATM | promptPIN(), readAccountNumber(), encrypt(), promptAmount(), dispenseCash() |
| Card | getAccountNumber() |
| Bank | verify(encAcc, encPIN) |
| Account | withdraw(amount), getBalance() |

#### Sequence diagram

```text
 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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which set are the collaborating objects identified for the ATM case?
   A. Customer, ATM, Card, Bank, Account
   B. Customer, Printer, Router
   C. ATM, Receipt, Teller
   D. Bank only
   Answer: A. The objects are Customer (actor), ATM, Card, Bank and Account. (Key point: Collaborating objects)

2. Which is the correct order of the first interactions?
   A. Bank verifies, then card is inserted
   B. Enter amount, then insert card
   C. Insert card, ATM prompts PIN, PIN entered, ATM gets account number from card
   D. ATM encrypts before the PIN is entered
   Answer: C. The card is inserted, the ATM prompts for the PIN, the PIN is entered, then the account number is read from the card. (Key point: Order of steps)

3. What does the ATM send to the Bank for verification?
   A. The plain PIN only
   B. The encrypted PIN and encrypted account number
   C. The cash amount only
   D. The card itself
   Answer: B. The ATM encrypts the PIN and account number and the bank verifies the encrypted data. (Key point: Encryption and verification)

4. What happens in the sequence diagram if the PIN is invalid?
   A. Cash is dispensed anyway
   B. The Account is closed
   C. The bank skips verification
   D. The bank returns 'invalid' and the ATM shows an error or retries (alt fragment)
   Answer: D. The alt fragment covers the failure case; only a valid PIN leads to 'Enter amount' and withdrawal. (Key point: Alternative flow)

5. After a valid PIN and amount entry, which object actually reduces the balance?
   A. Card
   B. Customer
   C. Account, through withdraw(amount) called via the Bank
   D. Only the ATM
   Answer: C. The ATM calls the bank, which calls withdraw on the Account (checking balance); then the ATM dispenses cash. (Key point: Withdrawal step)

## Related in Object Oriented Analysis and Design

- [Collaboration and use case diagram case](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Apopulation-system-collaboration-usecase) — Object Oriented Analysis and Design, chapter 2
- [Money transfer sequence diagram questions](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Amoney-transfer-sequence-diagram) — Object Oriented Analysis and Design, chapter 2
- [Math Training Institute use case diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Amath-training-institute-use-case) — Object Oriented Analysis and Design, chapter 2
- [Constraint specifications in bank account model](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aconstraint-specification-bank-account-model) — Object Oriented Analysis and Design, chapter 2
- [Coffee vending machine use case diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Acoffee-vending-machine-use-case) — Object Oriented Analysis and Design, chapter 2
- [XYZ Marina class diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Amarina-class-diagram) — Object Oriented Analysis and Design, chapter 2

## Related in other subjects

- [ATM in hotel card reader failure](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aatm-hotel-problem) — Instrumentation II, chapter 6
- [SQL: create and use bank database](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-create-database-bank) — Database Management System, chapter 3
- [SQL: create tables for bank schema](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-create-tables-bank) — Database Management System, chapter 3
- [Doubly linked list: bank customer records](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adoubly-bank-customer) — Data Structure and Algorithm, chapter 4
