Title: Case Study ATM Project
1Case Study ATM Project
2ATM System
BANK ----------------------- LoadAccounts S
aveAccounts VeryfyAccount MakeDeoposit MakeWithdra
wal GetBalance
ATM ----------------------- admin_ID admi
n_PIN ----------------------- PowerOn Login ServeC
ust Deposit Withdraw CheckBalance Shutdown
ACCOUNT ----------------------- id pin balance
----------------------- Deposit Withdraw GetBalan
ce GetID GetPIN
3Class Declaration include ltstringgt class
Account public //member functions
Account() Account(string initID,
string initPIN, double initBalance) void
Deposit(double amount) void Withdraw(double
amount) double GetBalance() string
GetID() string GetPIN() private
//data members double balance string
id string pin
ACCOUNT ----------------------- ID PIN Balance
----------------------- Deposit Withdraw GetBalan
ce getID getPIN
4Class declaration of Bank ifndef
BANK_H define BANK_H include
ltiostreamgt include ltfstreamgt include
ltstringgt include "account.h" using namespace
std class Bank public BankBank()
void LoadAccounts() void SaveAccounts()
bool VerifyAccount(string ID, string PIN)
void MakeDeposit(double amount) bool
MakeWithdraw(double amount) double
GetBalance() private Account
accounts100 int largestAccIndex int
currentAccIndex endif
BANK ----------------------- LoadAccounts S
aveAccounts VeryfyAccount MakeDeoposit MakeWithdra
wal GetBalance
ACCOUNT ----------------------- id pin balance
----------------------- Deposit Withdraw GetBalan
ce GetID GetPIN
5Class declaration of ATM ifndef ATM_H define
ATM_H include ltiostreamgt include
ltstringgt include ltfstreamgt include
"bank.h" using namespace std class
ATM public void PowerOn() void
Login() void ServeCust() void
Deposit() void Withdraw() void
CheckBalance() void Shutdown() private
string admin_ID string admin_PIN Bank
bank endif
BANK ----------------------- LoadAccounts S
aveAccounts VeryfyAccount MakeDeoposit MakeWithdra
wal GetBalance
ATM ----------------------- admin_ID admi
n_PIN ----------------------- PowerOn Login ServeC
ust Deposit Withdraw CheckBalance Shutdown
6ATM powers on
Account
Bank
ATM
PowerOn()
adminInfo.dat
LoadAccounts()
accInfo.dat
ifstream accInfo("accInfo.dat") largestAccIndex
-1 while(accInfogtgtidgtgtpingtgtamount)
largestAccIndex Account acc(id, pin,
amount) accountslargestAccIndex acc
Login()
7Login
Account
Bank
ATM
Login()
id,pin
alt
not admins id and pin
VerifyAccounts(id,pin)
y/n
alt
y
ServeCust()
login()
Shutdown()
8Serve Customer
Account
Bank
ATM
ServeCust
WDCT
alt
w
Withdraw()
D
Deposit()
C
ChechBalance()
T
Login()
9Check Balance
AccountscurrentIndex
Bank
ATM
CheckBalance()
GetBalance()
GetBalance()
Balance
Balance
ServeCust()
10Withdraw
AccountscurrentIndex
Bank
ATM
Withdraw()
Amount
MakeWithdraw()
Withdraw()
y/n
y/n
alt
y
print_success
ServeCust()
print_failure
ServeCust()
11Deposit
AccountscurrentIndex
Bank
ATM
Deposit()
MakeDeposit()
Deposit()
ServeCust()
12Shutdown
Account
Bank
ATM
Shutdown()
SaveAccounts()
accInfo.dat
ofstream accInfo("accInfo.dat") for (int
i0 iltlargestAccIndex i) accInfo
ltlt accountsi.GetID() ltlt " " ltlt
accountsi.GetPIN() ltlt " " ltlt
accountsi.GetBalance() ltlt "\n"