teacher
Sign in

ATM

Design an ATM with the State pattern for the card session and a chain of responsibility that picks which notes to dispense.

50 min5 interactive

Requirements

Start with questions. A short list shows the interviewer how you think, and each answer removes work.

QuestionDecision
What can a customer do?Insert a card, enter a PIN (Personal Identification Number), check balance, withdraw cash, eject the card
Who holds the money and the PINs?The bank, behind an interface. The ATM never stores balances
What notes does it hold?500, 200, 100 and 50, each with a stock count
What if the PIN is wrong?Three wrong tries and the card is retained
What if the machine cannot pay exactly?Refuse the withdrawal. The customer's account is not touched
Multiple customers at once?No. One card, one session at a time

Out of scope: deposits, transfers, receipts, the network protocol to the bank, hardware faults.

1 of 8