-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall_methods.cpp
More file actions
163 lines (160 loc) · 2.52 KB
/
all_methods.cpp
File metadata and controls
163 lines (160 loc) · 2.52 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include"head_atm.h"
#include<iostream>
using namespace std;
Card :: Card(int no,int p,Account* ac=0)
{
number=no;
pin=p;
acc=ac;
}
/*Card :: Card(const Card &c)
{
this->number=c.getnumber();
pin=c.getpin();
acc=c.getacc();
}*/
int Card :: getnumber()
{
return number;
}
int Card :: getpin()
{
return pin;
}
Account* Card :: getacc()
{
return acc;
}
bool Card :: validatePin(int p)
{
return(p==pin);
}
bool Account :: makeDeposit(int amt)
{
if(r_no<20)
{
rec[r_no].setrecord('d',r_no,amt);
r_no++;
}
balance+=amt;
return true;
}
bool Account :: makeWithdrawal(int amt)
{
if(r_no<20)
{
rec[r_no].setrecord('w',r_no,amt);
r_no++;
}
if(balance<amt)
{
return false;
}
else
{
balance=balance-amt;
return true;
}
}
/*void Account :: set_card(Card cd)
{
card=cd;
}*/
/*Account ::Account(int no,int bal,Card cd)
{
number=no;
balance=bal;
card=cd;
}*/
Account :: Account(int no,int bal)
{
number=no;
balance=bal;
r_no=0;
}
/*Account :: Account(const Account &ac)
{
number=ac.getnumber();
balance=ac.getbalance();
//card=ac.getcard()
}*/
int Account :: getnumber()
{
return number;
}
int Account :: getbalance()
{
return balance;
}
/*Card Account :: getcard()
{
return card;
}*/
void Account :: printrec()
{
int i;
for(i=0;i<r_no;i++)
{
cout<<"Number : "<<rec[i].number<<endl;
cout<<"Deposit(d)/Withdraw(w) : "<<rec[i].r<<endl;
cout<<"Amount : "<<rec[i].amount<<endl;
cout<<"Time : "<<rec[i].timeStamp<<endl<<endl;
}
}
bool ATM :: deposite(Card cd,int p,int amt)
{
startTransaction();
bool b;
if(cd.validatePin(p))
{
b=cd.acc->makeDeposit(amt);
}
else
{
b=false;
}
endTransaction();
return b;
}
bool ATM :: withdraw(Card cd,int p,int amt)
{
startTransaction();
bool b;
if(cd.validatePin(p))
{
b=cd.acc->makeWithdrawal(amt);
}
else
{
b=false;
}
endTransaction();
return b;
}
void ATM :: startTransaction()
{
t.num_running++;
}
void ATM :: endTransaction()
{
t.num_running--;
t.num_complete++;
}
Transaction :: Transaction()
{
num_running=0;
num_complete=0;
}
Record :: Record()
{
number=0;
amount=0;
r='n';
time_t timeStamp=time(0);
}
void Record :: setrecord(char ch,int no,int amt)
{
r=ch;
number=no;
amount=amt;
}