面向对象程序设计大作业(C++) 下载本文

float consumer::get_money() {return money;}

void main() {YH yh;

yh.functionshow(); }

/*主界面显示*/

void YH::functionshow() {

int n; do

{system(\load();

cout<<\<

cout<<\|\

cout<<\: 开户 |\

cout<<\|\

cout<<\:账户登录 |\

cout<<\|\

cout<<\:账户注销 |\

cout<<\|\

cout<<\:退出系统 |\

cout<<\|\

cout<<\<

cout<>n;

while(n<1||n>4) {

cout<<\您输入的数字有误!请重新输入...\ cout<<\→\ cin>>n; }

switch(n) {

case 1: set_account();//开户 break;

case 2:enter_account();//登录 break;

case 3: del_account();//注销 break;

case 4: exitYH();//退出 break; }

cin.get();//输入流类istream的成员函数 }

while(true); }

void YH::enter_account() {int id;

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

int flag = 1;

int i = 0; //__page_break__ while((i

if(id==account[i]->get_id()) flag = 0; else i++; }

if(flag) {

cout<<\帐号不存在!\return; }

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

if(passw!=account[i]->get_passwd()) return;//返回到登录界面 account[i]->display();cin.get();cin.get(); int n;

do{system(\

cout<<\请选择下列操作:\

cout<<\

cout<<\cout<<\查看账户信息 |\cout<<\cout<<\取款 |\cout<<\cout<<\存款 |\cout<<\cout<<\修改密码 |\cout<<\cout<<\转账 |\cout<<\cout<<\返回 |\cout<<\cout<<\cout<<\→\cin>>n;

switch(n)

{case 1: account[i]->display();break;

case 2: account[i]->fetchmoney();save();break;//从2-5功能,每执行一次调用一次save函数,重新写入数据

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; }

void consumer::change_passwd() {

string pwd,repwd;

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

cout<<\请确认新密码:\cin>>repwd; if(pwd!=repwd)

cout<<\对不起,您输入的两次密码不一致,按输入键返回上一层菜单!\else

cout<<\您好,您的密码已修改成功,请牢记并注意账号安全!\}

void consumer::fetchmoney() {

float m; char ch; do