模拟ATM机存取款管理系统面对对象课程设计

case 3:account[i]->savemoney();save();break; case 4:account[i]->change_passwd();save();break; case 5:transfer(i);save();break; case 6:return;

}cin.get();cin.get(); }

while(1); }

void YH::set_account() {

int id;

string nam; string passw; float m; string company;string address;int number;double in;

cout<<\请输入开户号:\ cin>>id;

cout<<\请输入开户人姓名:\ cin>>nam;

cout<<\请输入开户密码:\ cin>>passw;

cout<<\请输入存入金额:\ cin>>m; cout<<\请输入开户人电话:\ cin>>number;

cout<<\请输入开户人公司:\cin>>company;

cout<<\请输入开户人地址:\cin>>address;

cout<<\请输入开户人身份证号码:\cin>>in;

while(m<=0) {

cout<<\请输入正确的数字!\cin>>m; }

consumer * acc = new consumer(id,nam,number,in,company,address,passw,m); account[acnum] = acc;

cout<<\开户成功!!\ acnum++; save(); cin.get(); return; }

void YH::del_account() {

int id;

cout<>id; int flag = 1; int i = 0;

while((i

if(id == account[i]->get_id()) {

flag = 0; } else { i++; } }

if(flag) {

cout<<\该帐号不存在,请重新输入!\ return; //返回到登陆界面 }

for(int j=i;j

account[j] = account[j+1]; }

account[acnum-1]=NULL; acnum--; //账号总数自减一次

cout<<\你的账号已注销!!\ save(); cin.get(); return; }

(6)修改密码实现:

void consumer::change_passwd() {

string pwd,repwd;

cout<<\请输入新密码:\cin>>pwd;

cout<<\请再输入一次新密码:\cin>>repwd; if(pwd!=repwd)

cout<<\你输入的两次密码不一样,按输入键返回上一层菜单!\else

cout<<\密码修改成功,请牢记!\ }

(7)取/存款实现:

void consumer::fetchmoney() {

float m; char ch; do {

cout<\ cin>>m;

while(m<=0) {

cout<<\请输入正确的数字!\cout<<\→\cin>>m; }

if(money

cout<<\对不起,你的余额不足!\}

else

{money=money-m;

cout<

cout<<\是否要继续该项操作:(Y/N) \<>ch;

while(ch!='n'&&ch!='N'&&ch!='Y'&&ch!='y')//选择错误时判定

{

cout<<\→\cin>>ch; }

}while(ch=='y'||ch=='Y'); }

void consumer::savemoney()//存钱函数功能实现 {

float c; char ch; do {

cout<\ cin>>c;

while(c<=0) {

cout<<\输入错误,请重新输入!\cout<<\→\cin>>c; }

money=money+c;

cout<<\操作已成功!\

cout<<\是否要继续该项操作:(Y/N) \cout<<\→\cin>>ch;

while(ch!='n'&&ch!='N'&&ch!='Y'&&ch!='y') {

cout<<\→\cin>>ch; }

}while(ch=='y'||ch=='Y'); }

int YH::acnum=0;

(8)用户信息显示:

void consumer::display()//用户信息界面 {system(\

cout<<\cout<<\

cout<<\ 用户姓名:\cout<<\

cout<<\ 帐号: \cout<<\

cout<<\ 余额: \cout<<\

cout<<\ 按输入键回到上一菜单\cout<<\

cout<<\cout<<\→\}

6.系统测试 6.1首页

6.2开户页面

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4