Note: (Restricted functionality due to obvious reasons!)
Minimal Code ( Raw-View ) :
#include<iostream>
#include<conio.h>
#include<string.h>
#include<sstream>
int AccG = 10001, BankCash = 100000000;
using namespace std;
string getPassword()
{
string pwd;
char c = 10;
cout<<"\n Enter Password : ";
while(c != 13){
if(c != 10){
cout<<"*";
pwd += c;
}
c = getch();
};
cout<<endl;
return pwd;
}
class Bank
{
private:
string pwd;
public:
int accountNumber,bal;
string name;
Bank(){
accountNumber = AccG; AccG++;
bal = 0;
name = "N/A";
}
Bank(int initBal){
accountNumber = AccG; AccG++;
bal = 0;
name = "N/A";
bal = initBal;
}
void setPassword(){
this->pwd = getPassword();
}
void setName(string nm){ this->name = nm; }
void setName(){
string nm;
cout<<"\n Enter name : ";
nm="";
getline(cin,nm);
this->name = nm;
}
bool matchPassword(string pwd){
if(pwd == this->pwd){return true;}
return false;
}
void dep(int amt){ if(amt>=0) this->bal += amt;}
int withdraw(int amt){ if(amt>=0) this->bal -= amt;}
void dep(){
int amt;
cout<<"\n Enter amount : ";cin>>amt;
if(amt>=0) this->bal += amt;
}
int withdraw(){
int amt;
cout<<"\n Enter amount : ";cin>>amt;
if(amt>=0){
if(this->bal-amt>=0){
this->bal-= amt;
}else{
cout<<" In-sufficient Balance !! \n";}
return amt;
}
return 0;
}
};
void details(Bank acc1){
cout<<"\n\n ----- Account Details: --------\n";
cout<<" -- Acc.No. : "<< acc1.accountNumber <<endl;
cout<<" -- Name : "<< acc1.name<<endl;
cout<<" -- Balance : "<< acc1.bal<<endl;
}
int main(){
Bank acc1,acc2,acc3 = Bank(5000) , *currAcc;
string nm2 ="Some Given Name";
//acc1.setName();
acc2.setName(nm2);
//acc2.setPassword();
//acc1.setPassword();
int choice =0 , amt=0;
while(choice >= 0 ){
cout<<"\n 0 :- Update Name ";
cout<<"\n 1 :- Check Details ";
cout<<"\n 2 :- Deposit ";
cout<<"\n 3 :- Withdraw ";
cout<<"\n 4 :- EXIT. ";
cout<<endl<<"-- Enter Choice >> ";
cin>>choice;
if(choice == 0 ){
cout<<endl<<" Enter Name : ";
nm2="";cout<<" ";
getline(cin,nm2);
acc1.setName(nm2);
}
else if(choice == 1 ){ details(acc1); }
else if(choice == 2 ){ acc1.dep(); }
else if(choice == 3 ){ acc1.withdraw(); }
else if(choice >= 6 ){ break; }
};
cout<<"\n Set password for acc : ";
acc1.setPassword();
string inPwd = getPassword();
if(acc1.matchPassword(inPwd)){cout<<"\n Password Matched";}
else{cout<<" !!! Password - MISmatched !";}
details(acc1);
details(acc2);
details(acc3);
getch();
return 0;
}