-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClient.cpp
More file actions
76 lines (69 loc) · 1.55 KB
/
Client.cpp
File metadata and controls
76 lines (69 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//Client.cpp
#include"Client.h"
#include<sstream>
int bal;
Client::Client(){
this->bal=0.0;
setRole("Client");
}
void Client::deposit(double amount){
this->bal+= amount;
}
void Client::withdraw(double amount){
if(amount>this->bal){
cout<<"Overdrawn! Cannot complete"<<endl;
}
else{
this->bal-=amount;
}
}
void Client::print(){
cout<<"Client Account\n";
Account::print();
cout<<"Current balance: "<<this->bal<<endl;
}
string Client::toString(){
string output;
string balance;
stringstream amount;
amount>>bal;
balance=amount.str();
output=Account::toString()+" "+balance;
return output;
}
int Client::menu(){//Client menu
int choice;
cout <<"ATM\n"
<<"~~~~~~~~~~~~~~~~~~\n"
<<"1. Deposit\n"
<<"2. Withdrawl\n"
<<"3. View Balance\n";
<<"4. EXIT\n";
<<"\nEnter your choice: ";
cin >>choice;
return choice;
}
do
{ //choice controlled system
system("CLS");
option = menu();
switch(option)
{
case 1:cout << "Enter Amount";
cin >> transaction;
Deposit();
break;
case 2:cout << "Enter Amount";
cin >> transaction;
Withdraw();
break;
case 3:viewBal();
cout << "" <<bal<<"\n";
break;
case 4: cout <<"Goodbye";
break;
default: cout << "Invalid option!\n";
}
system("PAUSE");
}while(option != 4);
}