-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_management.cpp
executable file
·187 lines (161 loc) · 4.54 KB
/
bank_management.cpp
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <iostream>
#include <string.h>
#include <vector>
class User
{
private:
int balance;
std::string name, account_no, pin;
public:
User();
User(std::string, std::string, std::string, int);
// setter and getter
void setPin(std::string);
std::string getPin();
void setBalance(int);
int getBalance();
void setName(std::string);
std::string getName();
void setAccountNo(std::string);
std::string getAccountNo();
// Utility
// void createUser(std::string, std::string, std::string, int);
};
// Constructor
// void User::createUser()
// {
// this->setName(name);
// this->setAccountNo(acc_no);
// this->setPin(pin);
// this->setBalance(balance);
// }
User::User()
{
this->balance = 0;
}
User::User(std::string name, std::string acc_no, std::string pin, int balance)
{
this->name = name;
this->balance = balance;
this->account_no = acc_no;
this->pin = pin;
}
// All the setter and getter goes here
void User::setPin(std::string pin)
{
this->pin = pin;
std::cout << "Pin Set Successfully." << std::endl;
}
std::string User::getPin()
{
return this->pin;
}
void User::setBalance(int balance)
{
this->balance = balance;
}
int User::getBalance()
{
return this->balance;
}
void User::setName(std::string name)
{
this->name = name;
std::cout << "Name Added Successfully." << std::endl;
}
std::string User::getName()
{
return this->name;
}
void User::setAccountNo(std::string acc_no)
{
this->account_no = acc_no;
std::cout << "Account Number Added Successfully." << std::endl;
}
std::string User::getAccountNo()
{
return this->account_no;
}
// end of setter and getter
class Bank_Management
{
std::vector<User> user_arr;
public:
void addUser(User);
void showAccountDetails(std::string);
int showUserNumber();
};
// This is the Section of Utility Function
void Bank_Management::addUser(User user)
{
this->user_arr.push_back(user);
}
int Bank_Management::showUserNumber()
{
return this->user_arr.size();
}
void Bank_Management::showAccountDetails(std::string acc_no)
{
for (int i = 0; i < this->user_arr.size(); i++)
{
if (this->user_arr.at(i).getAccountNo() == acc_no)
{
std::cout << "A/C No: " << this->user_arr.at(i).getAccountNo() << std::endl;
std::cout << "Account Holder Name: " << this->user_arr.at(i).getName() << std::endl;
std::cout << "PIN: " << this->user_arr.at(i).getPin() << std::endl;
std::cout << "Balance: " << this->user_arr.at(i).getBalance() << "\n\n"
<< std::endl;
return;
}
}
std::cout << "User Not Found" << std::endl;
}
Bank_Management bank;
int main()
{
int balance, option = 10;
std::string name, acc_no, pin;
while (option != 0)
{
std::cout << "Select an Option From Below: " << std::endl;
std::cout << "1. Create an Account." << std::endl;
std::cout << "2. Balance Check." << std::endl;
std::cout << "3. Withdraw Money." << std::endl;
std::cout << "4. Add Money." << std::endl;
std::cout << "5. Change PIN" << std::endl;
std::cout << "6. Delete Account." << std::endl;
std::cout << "7. Show Account Details." << std::endl;
std::cout << "8. Show Total User." << std::endl;
std::cout << "9. Show all Account." << std::endl;
std::cout << "Select Option: ";
std::cin >> option;
system("cls");
std::cin.ignore(1, '\n');
if (option == 1)
{
std::cout << "Enter Your Name: ";
std::getline(std::cin, name);
std::cout << "Enter Your A/C No: ";
std::cin >> acc_no;
std::cout << "Enter Your PIN: ";
std::cin >> pin;
std::cout << "Enter Your Initial Deposit: ";
std::cin >> balance;
User u(name, acc_no, pin, balance);
bank.addUser(u);
std::cout << "User Successfully Created." << std::endl;
}
else if (option == 7)
{
std::cout << "Enter Your A/C Number: ";
std::cin >> acc_no;
system("cls");
bank.showAccountDetails(acc_no);
}
else if (option == 8)
{
std::cout << "Number of Total User: " << bank.showUserNumber() << std::endl;
}
}
return 0;
}