#include"iostream.h"
#include"stdlib.h"
#include"iomanip.h"
#include"conio.h"
struct Node
{
int card;
int password;
int money;
Node *next;
};
class card
{
public:
savelist(int,int);
checkNO(int);
checkpassword(int,int);
savemoney1(int,int);
savemoney2(int,int);
int getmoney(int );
changepassword(int,int);
outputlist1()
{
Node *current =head;
while(current!=NULL)
{
cout<<current->card<<endl;
cout<<current->password<<endl;
cout<<current->money<<endl;
current=current->next;
}
cout<<"Over"<<endl;
}
card()
{
head=NULL;
}
~card()
{
delete head;
}
deletelist(int);
private:
Node *head;
};
//int card:: checkNO (int n)
//{
// Node *p;
// p=head;
// while(p->card !=n&&p->next !=NULL)
// {
// p=p->next ;
// }
// if(p->card !=n&&p->next ==NULL) return 0;
// if(p->card ==n) return 1;
//}
int card::getmoney(int no)
{
Node *p;
p=head;
while(p->card!=no )
{
p=p->next ;
}
return p->money ;
}
int card:: checkpassword (int n,int ps)
{
Node *p,*q;
p=head;
while(p->card!=n &&p->next !=NULL)
{
q=p;
p=p->next ;
}
if(p->card !=n&&p->next ==NULL) return 0;
if(p->card ==n&&p->password==ps) return 1 ;
if(p->card ==n&&p->password !=ps) return 2;
}
card::changepassword (int no,int ps)
{
Node *p;
p=head;
while(p->card!=no )
{
p=p->next ;
}
p->password =ps;
}
card::savemoney1(int no,int money)
{
Node *p;
p=head;
while(p->card!=no )
{
p=p->next ;
}
p->money +=money;
}
card::savemoney2(int no,int money)
{
Node *p;
p=head;
while(p->card!=no )
{
p=p->next ;
}
if(money>(p->money)) return 0;
else {p->money -=money;return 1;}
}
card::savelist (int n,int ps)
{
Node *s,*p,*q;
s=new Node;
p=head;
s->card =n;
s->password =ps;
s->money =10;
s->next =NULL;
if(head==NULL)
{
head=s;
s->next =NULL;
cout<<" 保存成功"<<endl;
}
else
{
while(p->next !=NULL)
{
q=p;
p=p->next ;
}
p->next =s;
s->next =NULL;
cout<<"保存成功"<<endl;
}
}
card::deletelist(int n)
{
Node *p,*q;
p=head;
while(p->card !=n&&p!=NULL)
{
q=p;
p=p->next ;
}
if(p!=NULL)
{
q->next =p->next ;
delete p;
cout<<"delete succeed!"<<endl;
}
else cout<<"delete fail"<<endl;
}
void print(int no,int m,int money=0)
{
system("cls");
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<" 持卡人存根 "<<endl;
cout<<"+-----------------------------+--------------------------+"<<endl;
cout<<"+ 终端机号 +";
cout<<" 200807030141 +"<<endl;
cout<<"+ 卡别 +";
cout<<setw(15)<<" 信用卡 +"<<endl;
cout<<"+ 卡号 +";
cout<<setw(15)<<no<<" +"<<endl;
cout<<"+ 交易类型 +";
if(m==0) cout<<" 银行卡开户 +"<<endl;
if(m==1)
{
cout<<" 存钱 +"<<endl;
cout<<"+ 金额 +";
cout<<setw(15)<<money<<" +"<<endl;
}
if(m==2)
{
cout<<"取钱"<<endl;
cout<<"+ 金额 +";
cout<<setw(15)<<money<<" ++"<<endl;
}
cout<<"+-----------------------------+--------------------------+"<<endl;
cout<<"+ 持卡人签名 +";
cout<<" +"<<endl;
cout<<"+-----------------------------+--------------------------+"<<endl;
cout<<endl<<endl<<endl<<endl;
system("PAUSE");
system("cls");
}
int Chinese()
{
int l=0;
cout<<endl<<endl<<endl;
cout<<" 您好,欢迎光临zzuli学院银行! "<<endl<<endl<<endl<<endl;
cout<<" 1.ATM柜台机"<<endl<<endl;
cout<<" 2.银行业务管理"<<endl<<endl;
cout<<" 3.返回"<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"请选择:";
do
{
cin>>l;
if((l!=1)&&(l!=2)&&(l!=3))
cout<<"选择错误!"<<endl<<" 请重新输入:"<<endl;
}while((l!=1)&&(l!=2)&&(l!=3));
return l;
}
int pc2()
{
shuru:
int l;
//system("cls");
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<<"+ +"<<endl;
cout<<"+ 欢迎进入ATM系统 +"<<endl;
cout<<"+ +"<<endl;
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<<"+ +"<<endl;
cout<<"+ Please select your native language (请选择用户语言) +"<<endl;
cout<<"+ 1.中文 +"<<endl;
cout<<"+ 2.English +"<<endl;
cout<<"+ 3.Exit(退出) +"<<endl;
cout<<"+ +"<<endl;
cout<<"+ 请选择:";
//gotoxy(20,20);
cin>>l;
if((l!=1)&&(l!=2)&&(l!=3))
{ cout<<"选择错误!"<<endl<<endl;
goto shuru;}
system("cls");
return l;
}
void main()
{
card A;
A.savelist (777,777);
system("cls");
char c ;
int l,x,y,n,ps,no,flag,money,flag1;
logo:
l=pc2();
switch(l)
{
case 1:
ChinesePc:
n=Chinese();
switch(n)
{
case 1://ATM业务
cout<<endl;
cout<<" 请输入账号(0=取消):";
cin>>no;
while(no==0)
{
system("CLS");
goto ChinesePc;
}
shurumima:
cout<<endl;
cout<<" 请输入密码: ";
cin>>ps;
if(ps==0)
{
system("CLS");
goto ChinesePc;
}
y=A.checkpassword(no,ps);
switch(y)
{
case 0:
cout<<endl<<endl<<endl<<endl;
cout<<"账号不存在 "<<endl;
system("PAUSE");
system("cls");
goto ChinesePc;break;
case 1:
{ flag=0;flag1=1;
while(flag==0)
{
system("cls");
if(flag1==1)
{
cout<<"登陆成功!"<<endl<<endl;
flag1++;
}
cout<<endl<<endl<<endl<<endl;
cout<<" 个人银行业务:"<<endl<<endl<<endl;
cout<<" 1.人民币存款业务"<<endl<<endl;
cout<<" 2.人民币取款业务"<<endl<<endl;
cout<<" 3.余额查询"<<endl<<endl;
cout<<" 4.修改密码"<<endl<<endl;
cout<<" 5.返回"<<endl<<endl;
cout<<""<<endl;
cout<<""<<endl<<endl;
cout<<"请选择(1-5):";
cin>>n;
cout<<endl;
switch(n)
{
case 1:
{
cout<<"请将现金放入存钞口:";
cin>>money;
A.savemoney1(no,money);
cout<<"+---------------存款成功!-------------------------+"<<endl<<endl;
cout<<"需要打印凭条吗?(Y=是,N=否)"<<endl;
cin>>c;
while(c!='Y'&&c!='y'&&c!='n'&&c!='N')
{
cout<<"输入错误!请重新输入!(Y=是,N=否)"<<endl;
cin>>c;
}
if(c=='y'||c=='Y')
print(no,1,money);
}break;
case 2:
{
cout<<"请输入金额";
do
{
cin>>money;
l=A.savemoney2(no,money);
if(l==0) cout<<"超出您的余额,请重新输入"<<endl;
else cout<<"请收好您的现金"<<money<<"元"<<endl;
}while(l==0);
cout<<endl<<endl ;
cout<<"按任意键继续.....";
system("PAUSE");
}break;
case 3:
{
system("cls");
money=A.getmoney (no);