Design An ATM
Design An ATM
Design an ATM
An automated teller machine (ATM) is an electronic telecommunications instrument that provides the clients of a financial
institution with access to financial transactions in a public space without the need for a cashier or bank teller. ATMs are necessary
as not all the bank branches are open all days of the week, and some customers may not be in a position to visit a bank each time
they want to withdraw or deposit money.
ATM
The user can have two types of accounts: 1) Checking, and 2) Savings, and should be able to perform the following five
transactions on the ATM:
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 1/12
06/07/2019 Design an ATM
The user’s ATM card will be kept in the ATM until the user ends a session. For example, the user can end a session at any time by
pressing the cancel button, and the ATM Card will be ejected. The ATM will maintain an internal log of transactions that contains
information about hardware failures; this log will be used by the ATM operator to resolve any issues.
Use cases
Here are the actors of the ATM system and their use cases:
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 2/12
06/07/2019 Design an ATM
Balance inquiry
Deposit cash
<<extends>>
<<extends>>
Deposit
<<extends>>
Transaction <<extends>>
Deposit check
<<extends>> Cash withdraw
<<extends>>
Transfer
Login/Logout
Block/Unblock
account
Change pin
Customer
Bank
System startup
Check remaining
cash
Manager
Generate report System shutdown
Class diagram
Here are the main classes of the ATM System:
ATM: The main part of the system for which this software has been designed. It has attributes like ‘atmID’ to distinguish it
from other available ATMs, and ‘location’ which defines the physical address of the ATM.
CashReader: To encapsulate the ATM’s card reader used for user authentication.
Keypad: The user will use the ATM’s keypad to enter their PIN or amounts.
Screen: Users will be shown all messages on the screen and they will select different transactions by touching the screen.
Bank: To encapsulate the bank which ownns the ATM. The bank will hold all the account information and the ATM will
communicate with the bank to perform customer transactions.
Account: We’ll have two types of accounts in the system: 1)Checking and 2)Saving.
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 3/12
06/07/2019 Design an ATM
Customer: This class will encapsulate the ATM’s customer. It will have the customer’s basic information like name, email,
etc.
Card: Encapsulating the ATM card that the customer will use to authenticate themselves. Each customer can have one card.
Transaction: Encapsulating all transactions that the customer can perform on the ATM, like BalanceInquiry, Deposit,
Withdraw, etc.
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 4/12
06/07/2019 Design an ATM
UML conventions
<<interface>>
Name
Interface: Classes implement interfaces, denoted by Generalization.
method1()
ClassName
property_name: type Class: Every class can have properties and methods.
Abstract classes are identified by their Italic names.
method(): type
A B Generalization: A implements B.
Activity Diagram
Customer authentication: Following is the activity diagram for a customer authenticating themselves to perform an ATM
transaction:
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 5/12
06/07/2019 Design an ATM
[yes]
[yes]
[no]
Display Menu
Show error
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 6/12
06/07/2019 Design an ATM
[Predefined amount]
Enter amount
Is amount [yes]
greater than the Notify Customer
balance?
[no]
[yes]
Print
receipt?
Print receipt
[no]
Deposit check: Following is the activity diagram for the customer depositing a check:
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 7/12
06/07/2019 Design an ATM
is amount [no]
correct?
Add to balance
[yes]
Print
receipt?
Print receipt
[no]
Transfer: Following is the activity diagram for a user transferring funds to another account:
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 8/12
06/07/2019 Design an ATM
Insiffcient [no]
balance?
[yes]
[yes] retry?
Validate receiver's account
[valid account]
[no]
[yes]
Print
receipt?
Print receipt
[no]
Sequence Diagram
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 9/12
06/07/2019 Design an ATM
getBalance(Account)
balanceInquiryTransaction(Account)
getBalance()
getBalance()
Balance
Balance
Balance
displayMessage(Balance)
showMessage()
Code
Enums and Constants: Here are the required enums, data types, and constants:
1 public enum TransactionType {
2 BALANCE_INQUIRY, DEPOSIT_CASH, DEPOSIT_CHECK, WITHDRAW, TRANSFER
3 }
4
5 public enum TransactionStatus {
6 SUCCESS, FAILURE, BLOCKED, FULL, PARTIAL, NONE
7 }
8
9 public enum CustomerStatus {
10 ACTIVE, BLOCKED, BANNED, COMPROMISED, ARCHIVED, CLOSED, UNKNOWN
11 }
12
13 public class Address {
14 private String streetAddress;
15 private String city;
16 private String state;
17 private String zipCode;
18 private String country;
19 }
20
Customer, Card, and Account: “Customer” encapsulates the ATM user, “Card” the ATM card, and “Account” can be of two types:
checking and savings:
1 // For simplicity, we are not defining getter and setter functions. The reader can
2 // assume that all class attributes are private and accessed through their respective
3 // public getter method and modified only through their public setter function.
4
5 public class Customer {
6 private String name;
7 private String email;
8 private String phone;
9 private Address address;
10 private CustomerStatus status;
11
12 private Card card;
13 private Account account;
14
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 10/12
06/07/2019 Design an ATM
15 public boolean makeTransaction(Transactiopn transaction);
16 public Address getBillingAddress();
17 }
18
19 public class Card {
20 private String cardNumber;
21 private String customerName;
22 private Date cardExpiry;
23 private int pin;
24
25 public Address getBillingAddress();
Bank, ATM, CashDispenser, Keypad, Screen, Printer and DepositSlot: The ATM will have different components like keypad,
screen, etc.
1 public class Bank {
2 private String name;
3 private String bankCode;
4
5 public String getBankCode();
6 public boolean addATM();
7 }
8
9 public class ATM {
10 private int atmID;
11 private Address location;
12
13 private CashDispenser cashDispenser;
14 private Keypad keypad;
15 private Screen screen;
16 private Printer printer;
17 private CheckDeposit checkDeposit;
18 private CashDeposit cashDeposit;
19
20 public boolean authenticateUser();
21 public boolean makeTransaction(Customer customer, Transactiopn transaction);
22 }
23
24 public class CashDispenser {
25 private int totalFiveDollarBills;
Transaction and its subclasses: Customers can perform different transactions on the ATM, these classes encapsulate them:
1 public abstract class Transaction {
2 private int transactionId;
3 private Date creationTime;
4 private TransactionStatus status;
5 public boolean makeTransation();
6 }
7
8 public class BalanceInquiry extends Transaction {
9 private int accountId;
10 public double getAccountId();
11 }
12
13 public abstract class Deposit extends Transaction {
14 private double amount;
15 public double getAmount();
16 }
17
18 public class CheckDeposit extends Deposit {
19 private String checkNumber;
20 private String bankCode;
21
22 public String getCheckNumber();
23 }
24
25 public class CashDeposit extends Deposit {
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 11/12
06/07/2019 Design an ATM
https://www.educative.io/collection/page/5668639101419520/5692201761767424/5703128158568448 12/12