#include
#include
#include
#include
#include
#include
#include
using namespace std;
class ATM_Card{
private:
int ATM_PIN;
public:
ATM_Card(int pin){
ATM_PIN=pin;
}
int get_atm_pin()
{
return ATM_PIN;
}
void set_atm_pin(int pin1)
{
ATM_PIN=pin1;
cout<<"\nPIN changed successfully";
}
};
class ATM_Transaction {
private:
float balance;
int Transaction_PIN;
bool status;
int amount;
public:
ATM_Transaction(){
status=true;
balance=5000;
}
void set_transaction_pin(int pin);
void View_Balance();
void Withdraw();
void exit();
~ATM_Transaction(){
status=false;
cout<<"\nDestructor call : Transaction is ended\n";
}
};
int arr_pin[5]={3456,4349,3244,2431,5566};
void ATM_Transaction::set_transaction_pin(int pin)
{
Transaction_PIN=pin;
}
void ATM_Transaction::View_Balance()
{
cout<<"\n\t\t\t\tYour Balance is : "<
}
void ATM_Transaction::Withdraw()
{
cout<<"\nEnter Amount to withdraw : ";
cin>>amount;
if(amount >0 && amount < balance)
{
balance=balance-amount;
cout<<"\nWithdraw Succcess! New balance is : ";
cout<
}
else
cout<<"\nInsufficient balance in your account\n";
}
void ATM_Transaction::exit()
{
cout<<"\nTransaction is cancelled by the user\n";
}
int main() {
system ("Color 5f");
cout<<"\t\t\t--------------------\n"<
//Prompt to show today's date
cout << "\t\tCurrent date : ";
//Show date and time function
time_t now;
time(&now);
printf("%s\n", ctime(&now));;
//Give space for the function of date and time
cout<<"\t\t\t--------------------\n"<
cout<<"\tPress 1 and Then Press Enter to Access Your Account Via Pin Number\n\n";
int access;
cin>>access;
switch(access)
{
case 1://pin to access account
system("cls");int i, pin;
cout<<"\n\nEnter Your Acc Pin Access Number! [Only one attempt is allowed]\n\n"<
cin>>pin;
system("cls");
int user_choice,pin3,flag=0,y=1;
for(int i=0;i<5;i++)
if(arr_pin[i]==pin)
flag=1;
if(flag==0)
{
cout<<"\nTransaction Aborted! Wrong PIN";
return 0;
}
ATM_Card atm(pin);
ATM_Transaction transac;
transac.set_transaction_pin(atm.get_atm_pin());
while(y){
cout<<"\n\t\t\t\tWelcome user! Enter your choice\n\n";
cout<<"\t\t\t\t1. View Balance\n\t\t\t\t2. Withdraw money\n\t\t\t\t3. Change Card PIN\n\t\t\t\t4. Cancel Transaction\n";
cin>>user_choice;
switch(user_choice)
{
case 1:
transac.View_Balance();
break;
case 2:
transac.Withdraw();
break;
case 3:
cout<<"\nEnter new ATM pin: ";
cin>>pin3;
atm.set_atm_pin(pin3);
break;
case 4:
transac.exit();
return 0;
}
cout<<"\n\nDo you want to continue? \nPress 1 for continue and 0 to exit: ";
cin>>y;
cout<<"-------------------------\n";
system("cls");
}
return 0;
}
}