About

A simple ATM (Automated Teller Machine) system with three components:

Description

For maximum responsiveness, the components communicate without blocking. For example, atm_handler can’t call a function on user_interface directly, because doing so would stop it from handling other events.

At the start, the system waits for a card. Once a card is inserted, it waits for the user to enter a PIN one digit at a time. A valid PIN is 4 digits long. After the last digit, the system verifies the PIN. If the PIN is incorrect, the system ejects the card and waits for a new one. If the PIN is correct, the system waits for the user to cancel, display the balance, or withdraw 50. If the user cancels, the system ejects the card. If the user withdraws, the system waits for the bank to confirm. It then issues the cash or displays an “insufficient funds” message, and ejects the card. The system ignores every other user operation.

The code talks to the user and the bank through the interfaces in interface.hpp and bank.hpp. main.cpp drives the application.

Example

Please enter your card (i)
i
Please enter your PIN (0-9)
3412
PIN incorrect
Ejecting card
Please enter your card (i)
i
Please enter your PIN (0-9)
1234
Withdraw 50? (w)
Display Balance? (b)
Cancel? (c)
w
Issuing 50
b
The balance of your account is 50
c
Cancelled
Ejecting card
Please enter your card (i)
i
Please enter your PIN (0-9)
1234
Withdraw 50? (w)
Display Balance? (b)
Cancel? (c)
b
The balance of your account is 50
q

Notes

  • The functions are implemented in driver.cpp.

  • CMake build scripts are included, but any build system works.

  • You may add member variables, member functions, and types to the classes above as needed.

  • The solution compiles and runs without errors.

  • Unit tests are optional.

License