#include<bits/stdc++.h>
using namespace std;
class times//时间类
{
private:
int year,month,day;
public:
times(int a,int b,int c):year(a),month(b),day(c){}
times(){year=0;month=0;day=0;}
int getY(){return year;};
int getM(){return month;};
int getD(){return day;};
void showDate(){cout<<year<<"-"<<month<<"-"<<day<<endl;};
void setTime(int a,int b,int c){year=a;month=b;day=c;};
};
class consumer
{
private:
times t1;
char card[20];
char passward[20];
string name;
float money;
public:
consumer(char kk[],string name1,char pass[],float money1);
string getName(){return name;};
char *getCard(){return card;};
char *getPass(){return passward;};
float getMoney(){return money;};//left
void outMoney(int a){money-=a;};
void changePass(char pass[]){strcpy(passward,pass);};
void getDate(){t1.showDate();};
};
consumer::consumer(char kk[],string name1,char pass[],float money1)
{
strcpy(card,kk);
strcpy(passward,pass);
name=name1;
money=money1;
}
class atm
{
private:
consumer cons;
int time;
public:
void welcome();//主界面
void function();//功能界面
bool checkPass(char a[],char b[]);//1
void fetch();//2
void search();//3
void exitatm();//4
void lock();//5
void change();//6
};
void atm::welcome()
{
int time=0;
cout<<"欢迎使用本台atm机"<<endl;
char pass[20],cd[20],e;
int i;
do
{
i=0;
cout<<"请输入卡号"<<endl;
do
{
cin>>e;
cd[++i]=e;
}while(e!='/n');
i=0;
cout<<"请输入密码"<<endl;
do
{
cin>>e;
pass[++i]=e;
}while(e!='/n');
if(!checkPass(cd,pass))//判断函数
{
++time;
cout<<"您输入密码有误请重输"<<endl;
}
else function();
}while(time<3);
lock();
}
bool atm::checkPass(char a[],char b[])
{
if(strcmp(cons.getPass(),b)==0&&strcmp(cons.getCard(),a)==0)
return 1;
else return 0;
}
void atm::function()
{
cout<<"您想执行的操作序号为:"<<endl;
cout<<"1.查询余额"<<endl;
cout<<"2.修改密码"<<endl;
cout<<"3.取款"<<endl;
cout<<"4.退出系统"<<endl;
do
{
int n;
cin>>n;
while(n>4||n<1)//while语句
{cout<<"您输入的序号有误,请重输"<<endl;cin>>n;}
switch(n)
{
case 1:search();break;
case 2:change();break;
case 3:fetch();break;
case 4:exitatm();break;
}
}while(true);
}
void atm::search()
{
cout<<"***********"<<endl;
cout<<"卡号:"<<cons.getCard()<<endl;
cout<<"姓名: "<<cons.getName()<<endl;
cout<<"余额: "<<cons.getMoney()<<endl;
}
void atm::change()
{
char a[10],b[10];
int time=0,t;
do
{
cout<<"请输入旧密码"<<endl;
cin>>a;
if(!strcmp(cons.getPass(),a))
{
++time;
cout<<"密码错误,请重新输入"<<endl;
}
else break;
}while(time<3);
if (time==3)lock();
int flag=0;
do//细节问题
{
cout<<"请输入新密码"<<endl;
cin>>b;
cout<<"请再次输入密码"<<endl;
cin>>a;
if(flag=strcmp(a,b)!=0)
{
cout<<"两次密码不同,请重输"<<endl;
}
else
cout<<"修改密码成功,请牢记密码"<<endl;
cons.changePass(b);
}while(flag!=0);
}
void atm::fetch()
{
int no;
char e;
do
{
cout<<"您想取多少钱"<<endl;
cin>>no;
if(no%100!=0)
{
cout<<"请取规范的钱数"<<endl;
}
else if(cons.getMoney()<no)
{
couyt<<"余额不足"<<endl;
}
else
{
cout<<"取钱成功"<<endl;
cons.outMoney(no);
}
cout<<"您是否想继续操作(N/Y)"<<endl;
cin>>e;
if(e=='Y')
{
}
}while(e=='Y')
}
int main()
{
consumer con1("123456","李华","666666",9000);
/*cout<<con1.getName()<<endl;
con1.changePass("9999");
cout<<con1.getPass();*/
}
using namespace std;
class times//时间类
{
private:
int year,month,day;
public:
times(int a,int b,int c):year(a),month(b),day(c){}
times(){year=0;month=0;day=0;}
int getY(){return year;};
int getM(){return month;};
int getD(){return day;};
void showDate(){cout<<year<<"-"<<month<<"-"<<day<<endl;};
void setTime(int a,int b,int c){year=a;month=b;day=c;};
};
class consumer
{
private:
times t1;
char card[20];
char passward[20];
string name;
float money;
public:
consumer(char kk[],string name1,char pass[],float money1);
string getName(){return name;};
char *getCard(){return card;};
char *getPass(){return passward;};
float getMoney(){return money;};//left
void outMoney(int a){money-=a;};
void changePass(char pass[]){strcpy(passward,pass);};
void getDate(){t1.showDate();};
};
consumer::consumer(char kk[],string name1,char pass[],float money1)
{
strcpy(card,kk);
strcpy(passward,pass);
name=name1;
money=money1;
}
class atm
{
private:
consumer cons;
int time;
public:
void welcome();//主界面
void function();//功能界面
bool checkPass(char a[],char b[]);//1
void fetch();//2
void search();//3
void exitatm();//4
void lock();//5
void change();//6
};
void atm::welcome()
{
int time=0;
cout<<"欢迎使用本台atm机"<<endl;
char pass[20],cd[20],e;
int i;
do
{
i=0;
cout<<"请输入卡号"<<endl;
do
{
cin>>e;
cd[++i]=e;
}while(e!='/n');
i=0;
cout<<"请输入密码"<<endl;
do
{
cin>>e;
pass[++i]=e;
}while(e!='/n');
if(!checkPass(cd,pass))//判断函数
{
++time;
cout<<"您输入密码有误请重输"<<endl;
}
else function();
}while(time<3);
lock();
}
bool atm::checkPass(char a[],char b[])
{
if(strcmp(cons.getPass(),b)==0&&strcmp(cons.getCard(),a)==0)
return 1;
else return 0;
}
void atm::function()
{
cout<<"您想执行的操作序号为:"<<endl;
cout<<"1.查询余额"<<endl;
cout<<"2.修改密码"<<endl;
cout<<"3.取款"<<endl;
cout<<"4.退出系统"<<endl;
do
{
int n;
cin>>n;
while(n>4||n<1)//while语句
{cout<<"您输入的序号有误,请重输"<<endl;cin>>n;}
switch(n)
{
case 1:search();break;
case 2:change();break;
case 3:fetch();break;
case 4:exitatm();break;
}
}while(true);
}
void atm::search()
{
cout<<"***********"<<endl;
cout<<"卡号:"<<cons.getCard()<<endl;
cout<<"姓名: "<<cons.getName()<<endl;
cout<<"余额: "<<cons.getMoney()<<endl;
}
void atm::change()
{
char a[10],b[10];
int time=0,t;
do
{
cout<<"请输入旧密码"<<endl;
cin>>a;
if(!strcmp(cons.getPass(),a))
{
++time;
cout<<"密码错误,请重新输入"<<endl;
}
else break;
}while(time<3);
if (time==3)lock();
int flag=0;
do//细节问题
{
cout<<"请输入新密码"<<endl;
cin>>b;
cout<<"请再次输入密码"<<endl;
cin>>a;
if(flag=strcmp(a,b)!=0)
{
cout<<"两次密码不同,请重输"<<endl;
}
else
cout<<"修改密码成功,请牢记密码"<<endl;
cons.changePass(b);
}while(flag!=0);
}
void atm::fetch()
{
int no;
char e;
do
{
cout<<"您想取多少钱"<<endl;
cin>>no;
if(no%100!=0)
{
cout<<"请取规范的钱数"<<endl;
}
else if(cons.getMoney()<no)
{
couyt<<"余额不足"<<endl;
}
else
{
cout<<"取钱成功"<<endl;
cons.outMoney(no);
}
cout<<"您是否想继续操作(N/Y)"<<endl;
cin>>e;
if(e=='Y')
{
}
}while(e=='Y')
}
int main()
{
consumer con1("123456","李华","666666",9000);
/*cout<<con1.getName()<<endl;
con1.changePass("9999");
cout<<con1.getPass();*/
}