<a target=_blank href="http://pan.baidu.com/s/1mg9sVyw">点击打开链接</a>
officer 账户100-104 密码123456
customer 账户10000-10099 密码123456
<pre name="code" class="cpp">/*
* 版权所有(c) 2015, 烟台大学计算机学院
* 文件名称: mian.cpp
* 文件标识:无
* 内容摘要:程序实现的主函数
* 其它说明:无
* 当前版本: V1.0
* 作 者:刘志力
* 完成日期:2015.7.17
* 修改记录:0
* 修改日期
* 版本号: V1.0
* 修改人:
* 修改内容:
*/
#include<iostream> //C++标准头文件
#include<fstream> //从文件中读数据包含的头文件
#include <windows.h> //system,Sleep,exit函数的调用需要的头文件
#include<conio.h> //调用getch需要用到的头文件
#include"bank.h"
/*
*函数名称:back__menu
*功能描述:当用户输入“0”时退出,否则停留在原状态
*输入参数:无
*输出参数:无
*返回值:无
*其他说明:无
*/
void back_menu()
{
int iBack;
cout<<"\n0.返回工作菜单\n";
while((iBack=getch())!='0')
{
;
}
}
int main()
{
Bank a; //定义银行类
Officer * b=NULL; //定义一个职员对象指针,并初始化为NULL
b=a.find_officer(); //将find_officer()返回的指针赋值给c
if(b!=NULL) //首先判断b是否为空指针,如果为空直接退出
{
bool q=false;
q=(*b).login(); //职员登陆
if(q) //如果登陆,进入工作,否者直接退出系统
{
system("cls"); //清屏
while(1) //switch语句"1"为工作"2"为退出
{
int g=1;
cout<<"1.工作\t"<<"2.退出"<<endl;
cin>>g;
system("cls"); //清屏
switch(g)
{
case 1:
{
cout<<"信息加载中\n";
a.load_customer_search(); //加载customer的索引
Customer *c=NULL; //定义客户为的指针对象,并初始化为空
system("cls"); //清屏
int i=1;
while(i!=10)
{
int search_located=0; //Internet型数据,在对客户操作时读入用户的索引序列
system("cls");
cout<<" *********程序员银行*********"<<endl;
cout<<" 当前操作员:"<<(*b).get_name()<<endl;
cout<<"1.开户\t\t\t\t"<<"2.存钱"<<endl;
cout<<"3.取钱\t\t\t\t"<<"4.信息查询"<<endl;
cout<<"5.转账\t\t\t\t"<<"6.改密"<<endl;
cout<<"7.挂失\t\t\t\t"<<"8.解挂"<<endl;
cout<<"9.销户\t\t\t\t"<<"10.退出"<<endl;
cin>>i;
switch(i) //switch
{
case 1: //开户
{
system("cls");
a.open_account(); //调用Bank类的open_account()函数
back_menu();
break;
}
case 2:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located); //调用Bank类的find_customer(int)函数
if(c!=NULL)
{
(*c).saveMoney(); //调用Customer类的saveMoney()函数
a.save_customer(*c,search_located);//调用Bank类的save_customer(Customer*,int)函数存储数据
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 3:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located); //调用Customer类的find_customer(int)函数
if(c!=NULL)
{
(*c).drawMoney(); //调用Customer类的drawMoney()函数
a.save_customer(*c,search_located);//调用Bank类的save_customer(Customer*,int)函数存储数据
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 4:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located);//调用Customer类的find_customer(int)函数
if(c!=NULL)
{
(*c).showCustomer(); //调用Customer类的showCustomer()函数
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 5:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located);//调用Customer类的find_customer(int)函数
if(c!=NULL)
{
(*c).transferAccount(&a); //调用Customer类的transferAccount(Bank&)函数
a.save_customer(*c,search_located);//调用Bank类的save_customer(Customer*,int)函数存储数据
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 6:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located);//调用Customer类的find_customer(int)函数
if(c!=NULL)
{
(*c).changePassword(); //调用Customer类的chagnePassword()函数
a.save_customer(*c,search_located);//调用Bank类的save_customer(Customer*,int)函数存储数据
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 7:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located);//调用Customer类的find_customer(int)函数
if(c!=NULL)
{
(*c).turnLost(); //调用Customer类的turnLost()函数
a.save_customer(*c,search_located);//调用Bank类的save_customer(Customer*,int)函数存储数据
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 8:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located);//调用Customer类的find_customer(int)函数
if(c!=NULL)
{
(*c).turnUnlost(); //调用Customer类的turnUnlost()函数
a.save_customer(*c,search_located);//调用Bank类的save_customer(Customer*,int)函数存储数据
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 9:
{
system("cls");
c=new Customer;
c=a.find_customer(search_located);//调用Customer类的find_customer(int)函数
if(c!=NULL)
{
a.close_account(c,search_located);//调用Bank类的close_account(Customer*,int)函数
}
else
{
cout<<"该账户不存在"<<endl;
}
delete c;
back_menu();
break;
}
case 10:
{
system("cls");
cout<<"退出中";
Sleep(2000);
system("cls");
a.release();
exit(1);
}
}
}
}
case 2:
exit(1);
}
}
}
}
else
{
cout<<"the account don't exist";
Sleep(2000);
exit(1);
}
}
</pre><pre name="code" class="cpp">
<pre name="code" class="cpp">/*
*版权所有(c) 2015, 烟台大学计算机学院
* 文件名称:bank.h
* 文件标识:无
* 内容摘要:bank类,customer类,officer类的声明,customer_search结构体的声明
* 其它说明:无
* 当前版本: V1.0
* 作 者:刘志力
* 完成日期:2015.7.17
* 修改记录:0
* 修改日期
* 版本号: V1.0
* 修改人:
* 修改内容:
*/
#ifndef BANK_H_INCLUDED
#define BANK_H_INCLUDED
#include<cstring>
using namespace std;
class Bank;
class Officer;
class Customer;
/*
*结构体名称:customer_search
*说明:保存索引的信息
*/
struct customer_search
{
int num;
int account;
bool state;
customer_search *next;
};
/*
*类名称:Bank
*说明:建立银行类,银行类读入职员,客户,索引的信息,以及进行开户,销户,存储用户信息的函数
*/
class Bank
{
private:
int off_NO; //已存入的officer数量
int search_NO; //已存入的索引数量
int cus_NO; //已存在的customner账户数
Officer *off; //定义的Officer指针
customer_search *cus_search; //定义的customer_serach的指针
public:
Bank(); //默认构造函数
void open_account(); // 开户函数
void close_account(Customer*a,int b); //销户函数
void save_customer(Customer&a,int b); //存储用户信息
void load_customer_search(); //加载customer的索引
Officer* find_officer(); //查找职员的函数,
Customer* find_customer(int &a); //查找用户的函数,并返回该用户的指针
void release(); //释放链表cus_search和职员off的空间
~Bank() {};
};
/*
*类的名称:Officer
*说明:职员类保存职员的名字,账号,身份证,密码
*/
class Officer
{
protected:
int iOff_account; //职员账号
char cOff_name[20]; //姓名
char cOff_idcard[18]; //身份证
int iOff_password; //密码
public:
Officer(); //无参构造函数
Officer(int a,char* b,char* c,int d); //有参构造函数
bool login(); //用户登录函数
char* get_name(); //得到用户的名字的函数
int get_account(); //返回用户的账户
~Officer() {};
//析构函数用于将保存用户的交易记录,但可行性有待考虑
friend Bank; //声明为bank类的友元类
};
/*
*类的名称:Customer
*说明:继承Officer类,并增加存款,挂失状态的信息,以及存款,取款,查询,转账,改密码,挂失,解挂的成员函数
*/
class Customer:public Officer
{
private:
double dCus_money; //客户的账户余额
bool bCus_lost; //挂失为true,没有挂失为false
public:
Customer(); //无参构造函数
Customer(int a); //有参构造函数
Customer(int a,char* b,char* c,int d,double e,bool f):Officer(a,b,c,d) //有参构造函数
{
dCus_money=e,bCus_lost=f;
}
void saveMoney(); //存钱函数
void drawMoney(); //取钱函数
void showCustomer(); //信息查询函数
void transferAccount(Bank *bank); //转账函数
void changePassword(); //修改密码函数
void turnLost(); //挂失函数
void turnUnlost(); //解挂函数
void closeAccount(Customer*a,int b); //销户函数
~Customer() {}; //析构函数
friend Bank ; //声明为bank的友元类
};
#endif // BANK_H_INCLUDED
</pre><pre name="code" class="cpp"><pre name="code" class="cpp">/*
*版权所有(c) 2015, 烟台大学计算机学院
* 文件名称: bank.cpp
* 文件标识:无
* 内容摘要:bank类,customer类,officer类的函数的实现
* 其它说明:无
* 当前版本: V1.0
* 作 者:刘志力
* 完成日期:2015.7.17
* 修改记录:0
* 修改日期
* 版本号: V1.0
* 修改人:
* 修改内容:
*/
#include<iostream> //C++标准头文件
#include<fstream> //操作文件的头文件
#include <windows.h> //清屏函数的调用需要的头文件
#include<conio.h> //调用getch需要用到的头文件
#include<stdlib.h> //exit()必要的头文件
#include"bank.h"
using namespace std;
//**************全局函数************
int get_password()
{
int password=0;
int m;
for(int i=0; i<6;)
{
m=getch()-48;
if(m>=0&&m<=9)
{
cout<<'*';
(password*=10)+=m;
i++;
}
}
return password;
}
//***************Bank类的成员函数的定义*********************
/*
*函数名称:Bank
*功能描述:Bank的默认构造函数
*输入参数:无
*输出参数:读入off,和off_NO
*返回值:无
*其他说明:从文件读入读入职员off
*/
Bank::Bank()
{
ifstream infile("officer.txt",ios::ate|ios::binary);
if(!infile)
{
cerr<<"officer information load fail";
exit(1);
}
else
{
infile.seekg(ios::beg);
infile.read((char*)&off_NO,sizeof(off_NO));
off=new Officer[off_NO];
int i;
for(i=0; i<off_NO; i++)
{
infile.read((char*)&off[i],sizeof(off[i]));
}
infile.close();
}
}
/*
*函数名称:open_account
*功能描述:开户的函数
*输入参数:无
*输出参数:将索引的链表加上新增的数据,将客户数量,索引的数量加1
*返回值:无
*其他说明:函数中对相应的"customer_search.txt","customer.txt"文件进行修改
*/
void Bank::open_account() //银行的开户函数
{
char name[20]; //输入开户用户的信息
char idcard[18];
int password;
cout<<"******开户******";
cout<<"输入姓名:";
cin>>name;
cout<<"输入身份证号:";
int i=0;
char m;
while((m=getch())!=13&&i<18)
{
cout<<m;
idcard[i]=m;
i++;
}
cout<<endl<<"输入密码:";
password=get_password();
customer_search *sear; //为开户用户建立索引
sear=new customer_search;
(*sear).num=search_NO;
(*sear).account=search_NO+10000;
(*sear).state=true;
ofstream outfile1("customersearch.txt",ios::ate|ios::binary|ios::in|ios::out);
if(!outfile1)
{
cerr<<"文件加载失败"<<endl;
exit(1);
}
int NO=search_NO;
search_NO++; //索引的数量增加1
outfile1.seekp(ios::beg); //存入索引
outfile1.write((char*)&search_NO,sizeof(search_NO));
outfile1.seekp(NO*sizeof(sear[0]),ios::cur);
outfile1.write((char*)&sear[0],sizeof(sear[0]));
outfile1.close();
customer_search *t;
t=cus_search; //在链表追加上新增的数据
do
{
t=t->next;
}
while((*t).next!=NULL);
(*t).next=sear;
sear->next=NULL;
Customer p(sear->account,name,idcard,password,0,false); //建立一个customer类,
fstream outfile2("customer.txt",ios::ate|ios::binary|ios::in|ios::out);
if(!outfile2)
{
cerr<<"文件加载失败"<<endl;
exit(1);
}
outfile2.seekg(ios::beg);
outfile2.read((char*)&cus_NO,sizeof(cus_NO));
cus_NO++; //客户的数量增加1
outfile2.seekp(ios::beg);
outfile2.write((char*)&cus_NO,sizeof(cus_NO));
outfile2.seekp(NO*sizeof(p),ios::cur);
outfile2.write((char*)&p,sizeof(p));
outfile2.close();
system("cls");
cout<<"开户成功"<<endl;
cout<<"账户号码为:"<<sear->account<<endl;
}
/*
*函数名称:close_account
*功能描述:销户的函数
*输入参数:需要销户的指针,及用户所在的位置即用户的索引序列
*输出参数:修改索引的链表上相应的数据,将客户数量减1
*返回值:无
*其他说明:函数中对相应的"customer_search.txt","customer.txt"文件进行修改
*/
void Bank::close_account(Customer*a,int b) //银行类的销户函数
{
system("cls");
bool k;
k=(*a).login();
if(k)
{
if(!(*a).bCus_lost)
{
customer_search *u;
u=new customer_search;
u=cus_search;
int i=0;
while(i<b)
{
u=u->next;
i++;
}
if((*a).dCus_money!=0)
{
cout<<"取出余额:"<<(*a).dCus_money<<endl;
}
ofstream outfile1("customersearch.txt",ios::binary|ios::ate|ios::in|ios::out);
if(!outfile1)
{
cerr<<"文件加载失败"<<endl;
exit(1);
}
u[0].state=false;
outfile1.seekp(ios::beg);
outfile1.seekp(sizeof(int),ios::beg);
outfile1.seekp(b*sizeof(u[0]),ios::cur);
outfile1.write((char*)&u[0],sizeof(u[0]));
outfile1.close();
Customer p((*a).iOff_account);
ofstream outfile2("customer.txt",ios::binary|ios::ate|ios::out|ios::in);
if(!outfile2)
{
cerr<<"文件加载失败"<<endl;
exit(1);
}
cus_NO--;
outfile2.seekp(ios::beg);
outfile2.write((char*)&cus_NO,sizeof(cus_NO));
outfile2.seekp(b*sizeof(p),ios::cur);
outfile2.write((char*)&p,sizeof(p));
outfile2.close();
cout<<"销户成功"<<endl;
}
else
cout<<"当前账号处于挂失状态,不能销户"<<endl;
}
else
cout<<"密码错误"<<endl;
}
/*
*函数名称:load_account_search
*功能描述:将用户的索引读入到定义的customer_serach的指针
*输入参数:无
*输出参数:读入索引的数量和和索引链表
*返回值:无
*其他说明:索引用链表保存,运行结束的时需将相应的分配空间删除
*/
void Bank::load_customer_search() //加载customer的索引
{
ifstream infile("customersearch.txt",ios::ate|ios::binary);
if(!infile)
{
cerr<<"customersearch information load fail";
exit(1);
}
else
{
int i;
infile.seekg(ios::beg);
infile.read((char*)&search_NO,sizeof(search_NO));
customer_search *p,*q;
for(i=0; i<search_NO; i++)
{
p=new customer_search;
infile.read((char*)&p[0],sizeof(p[0]));
if(i==0)
{
cus_search=p;
}
else
{
q->next=p;
}
q=p;
}
q->next=NULL;
infile.close();
}
}
/*
*函数名称:save_customer
*功能描述:将用户操作后数据读入文件
*输入参数:需读入数据的引用,及用户所在的位置即用户的索引序列
*输出参数:无
*返回值:无
*其他说明:保存结束后删除bank对象的cus客户指针的空间
*/
void Bank::save_customer(Customer&a,int b) //存储用户信息
{
ofstream outfile("customer.txt",ios::ate|ios::binary|ios::in|ios::out);
if(!outfile)
{
cerr<<"save file load fail";
exit(1);
}
outfile.seekp(sizeof(int),ios::beg);
outfile.seekp(b*sizeof(a),ios::cur);
outfile.write((char*)&a,sizeof(a));
outfile.close();
}
/*
*函数名称:find_customer
*功能描述:查找相应的用户,并返回用户的指针
*输入参数:int型数据的引用
*输出参数:并将该用户的索引序号赋值给b
*返回值:相应用户的指针
*其他说明:查找过程中通过判断该账号对应的索引的状态来判断该用户是否存在
*/
Customer* Bank::find_customer(int &a) //查找客户的函数
{
customer_search *cus_find; //定义一个customer_search的索引指针
cus_find=cus_search; //将读入的链表的head副职给cus_find
int NO;
cout<<"输入账号:";
cin>>NO;
int i=0;
for(i=0; i<search_NO; i++)
{
if(cus_find->account==NO&&cus_find->state==1)
{
Customer *cus;
cus=new Customer; //为定义的cus 分配空间
a=i;
ifstream infile("customer.txt",ios::binary);
infile.read((char*)&cus_NO,sizeof(cus_NO));
infile.seekg(i*sizeof(cus[0]),ios::cur);
infile.read((char*)&cus[0],sizeof(cus[0]));
infile.close();
return cus;
}
else
{
cus_find=cus_find->next;
}
}
return NULL;
}
/*
*函数名称:find_Officer
*功能描述:查找相应的职员,并返回职员的指针
*输入参数:无
*输出参数:无
*返回值:相应职员的指针
*其他说明:通过输入的账号与读入的off指针比较,判断输入的账号是否存在
*/
Officer* Bank::find_officer() //查找职员的函数
{
int a;
cout<<"输入账号:";
cin>>a;
int i=0;
for(i=0; i<off_NO; i++)
{
if(off[i].iOff_account==a)
return &off[i];
}
return NULL;
}
/*
*函数名称:release
*功能描述:释放索引链表指针cus_search和职员指针off的空间
*输入参数:无
*输出参数:无
*返回值:无
*其他说明:索引链表指针cus_search和职员指针off的空间为动态分配空间,所以在运行结束时要释放相应的空间
*/
void Bank::release() //释放链表cus_search和职员off的空间
{
customer_search *p;
p=cus_search;
for(int i=0; i<search_NO; i++)
{
cus_search=cus_search->next;
delete p;
p=cus_search;
}
delete off;
}
//*********officer类的成员函数**************
/*
*函数名称:Officer
*功能描述:Officer的无参构造函数
*输入参数:无
*输出参数:对象Officer中的数据成员初始化
*返回值:无
*其他说明:无
*/
Officer::Officer() //对officer的初始化
{
iOff_account=-1;
*cOff_name='\0';
*cOff_idcard='\0';
iOff_password=-1;
}
/*
*函数名称:Officer
*功能描述:Officer的有参重载构造函数
*输入参数:无
*输出参数:对象Officer中的数据成员初始化
*返回值:无
*其他说明:Officer中的cOff_name,cOff_idcard通过深复制的方法进行复制
*/
Officer::Officer(int a,char *b,char *c,int d)
{
iOff_account=a;
for(int i=0; i<20; i++)
{
cOff_name[i]=b[i];
}
for(int j=0; j<18; j++)
{
cOff_idcard[j]=c[j];
}
iOff_password=d;
}
/*
*函数名称:get_name
*功能描述:得到用户名字的函数
*输入参数:无
*输出参数:无
*返回值:职员的名字cOff_name
*其他说明:无
*/
char *Officer::get_name()
{
return cOff_name;
}
/*
*函数名称:get_account
*功能描述:得到用户账户的函数
*输入参数:无
*输出参数:无
*返回值:职员的名字iOff_account
*其他说明:无
*/
int Officer::get_account()
{
return iOff_account;
}
/*
*函数名称:login
*功能描述:职员的登录函数
*输入参数:无
*输出参数:无
*返回值:bool类型的值,登录则返回true,否则返回为
*其他说明:Officer中的cOff_name,cOff_idcard通过深复制的方法进行复制
*/
bool Officer::login() //登陆函数
{
int password=0,n=0;
bool b=false;
while(n<3&&!b)
{
cout<<"输入密码:";
password=get_password();
if(iOff_password==password)
{
b=true;
cout<<'\n'<<cOff_name<<endl;
cout<<"登陆成功"<<endl;
}
else
{
cout<<"\n密码错误"<<endl;
++n;
Sleep(500);
system("cls");
cout<<"今日还有"<<3-n<<"次输入机会"<<endl;
}
}
system("cls");
return b;
}
//***********customer类的成员函数的定义***********
/*
*函数名称:Customer
*功能描述:Customer的默认构造函数
*输入参数:
*输出参数:对customer的数据成员赋值
*返回值:无
*其他说明:无
*/
Customer::Customer()
{
dCus_money=0;
bCus_lost=false;
}
/*
*函数名称:Customer
*功能描述:Customer的重载构造函数
*输入参数:账户号码
*输出参数:对customer的数据成员赋值
*返回值:无
*其他说明:无
*/
Customer::Customer(int a)
{
iOff_account=a;
*cOff_name='\0';
*cOff_idcard='\0';
iOff_password=-1;
dCus_money=0;
bCus_lost=false;
}
/*
*函数名称:saveMoney
*功能描述:存钱
*输入参数:无
*输出参数:如果成功则改变dCus_money的值
*返回值:无
*其他说明:只修改对象的数据值,不进行文件存储,不需要登录
*/
void Customer::saveMoney()
{
double money;
cout<<"输入存款金额:";
cin>>money;
system("cls");
cout<<"姓名:"<<cOff_name<<endl;
int i;
cout<<"存款金额:"<<money<<endl;
cout<< "1.确认 2.取消"<<endl;
cin>>i;
system("cls");
switch(i)
{
case 1:
dCus_money+=money;
cout<<"存款成功"<<endl;
break;
case 2:
cout<<"取消成功"<<endl;
break;
}
}
/*
*函数名称:drawMoney
*功能描述:取钱
*输入参数:无
*输出参数:如果成功则改变dCus_money的值
*返回值:无
*其他说明:只修改对象的数据值,不进行文件存储。其中包括登录函数
*/
void Customer::drawMoney() //客户类的取钱函数
{
bool k;
k=Customer::login();
if(k)
{
if(!bCus_lost)
{
double money;
cout<<"输入取款金额:";
cin>>money;
cout<<endl;
if(money<=dCus_money)
{
int i;
system("cls");
cout<<"取款金额:"<<money<<endl;
cout<< "1.确认 2.取消"<<endl;
cin>>i;
system("cls");
switch(i)
{
case 1:
dCus_money-=money;
cout<<"取款成功"<<endl;
break;
case 2:
cout<<"取消成功"<<endl;
break;
}
}
else
{
cout<<"余额不足"<<endl;
}
}
else
cout<<"当前账号处于挂失状态,不能取款"<<endl;
}
}
/*
*函数名称:showCustomer
*功能描述:用户信息查询
*输入参数:无
*输出参数:如果成功则改变dCus_money的值
*返回值:无
*其他说明:只修改对象的数据值,不进行文件存储。其中包括登录函数
*/
void Customer::showCustomer() //客户类的信息查询函数
{
bool k;
k=Customer::login();
system("cls");
if(k)
{
cout<<"账号:"<<iOff_account<<endl;
cout<<"姓名:"<<cOff_name<<endl;
cout<<"身份证号码:"<<cOff_idcard<<endl;
cout<<"余额:"<<dCus_money<<endl;
cout<<"状态:";
if(bCus_lost)
cout<<"挂失"<<endl;
else
cout<<"正常"<<endl;
}
}
/*
*函数名称:showCustomer
*功能描述:用户信息查询
*输入参数:Bank的指针
*输出参数:如果成功则改变dCus_money的值
*返回值:无
*其他说明:只修改对象的数据值,不进行文件存储。其中包括登录函数,其中建立了一个存入的客户对象指针并分配空间,存储过相应的数据后释放该空间
*因为转账函数中需要查找用户所以输入参数需写入Bank*,使用时将预先定义的Bank全局变量的指针写作函数的参数
*/
void Customer::transferAccount(Bank *bank) //客户类的转账函数
{
if(Customer::login())
{
if(!bCus_lost)
{
int t=0;
Customer*k;
k=new Customer;
cout<<"转入:\n";
k=bank->find_customer(t);
if(k!=NULL)
{
double money;
cout<<"输入转账金额:";
cin>>money;
cout<<endl;
if(money>0)
{
system("cls");
if(money<=dCus_money)
{
cout<<"转出金额:"<<money<<endl;
cout<<"转入账号:"<<(*k).get_account()<<endl;
int i;
cout<<"1.确认 2.取消"<<endl;
cin>>i;
system("cls");
switch(i)
{
case 1:
dCus_money-=money;
(*k).dCus_money+=money;
cout<<"转账成功"<<endl;
break;
case 2:
break;
}
}
else
cout<<"余额不足"<<endl;
}
else
cout<<"转账金额需大于0元"<<endl;
}
else
{
cout<<"你输入的账户不存在"<<endl;
}
bank->save_customer(*k,t);
delete k;
}
else
{
cout<<"当前账号处于挂失状态,不能转账"<<endl;
}
}
else
cout<<"密码错误"<<endl;
}
/*
*函数名称:changePassword
*功能描述:用户密码修改
*输入参数:无
*输出参数:如果成功则改变密码
*返回值:无
*其他说明:只修改对象的数据值,不进行文件存储。其中包括登录函数
*/
void Customer::changePassword() //修改密码的函数
{
if(!bCus_lost)
{
int p,j,k;
cout<<"输入原密码:";
p=get_password();
system("cls");
if(iOff_password==p)
{
cout<<"输入新密码:";
j=get_password();
cout<<"\n再次输入密码:";
k=get_password();
system("cls");
if(j==k)
{
iOff_password=j;
cout<<"密码修改成功\n";
}
else
cout<<"\n两次输入的密码不相同修改失败";
}
else
cout<<"\n密码错误";
}
else
cout<<"\n当前用户处于挂失状态无法修改密码";
}
/*
*函数名称:turnLost
*功能描述:用户挂失
*输入参数:无
*输出参数:如果成功则改变bCus_state的值
*返回值:无
*其他说明:只修改对象的数据值,不进行文件存储。其中包括登录函数
*/
void Customer::turnLost() //客户类的挂失函数
{
bool k;
k=Customer::login();
if(k)
{
if(!bCus_lost)
{
bCus_lost=true;
cout<<"挂失成功"<<endl;
}
else
cout<<"你账号已挂失"<<endl;
}
else
cout<<"密码错误"<<endl;
}
/*
*函数名称:turnUnlost
*功能描述:用户解挂函数
*输入参数:无
*输出参数:如果成功则改变bCus_state的值
*返回值:无
*其他说明:只修改对象的数据值,不进行文件存储。其中包括登录函数
*/
void Customer::turnUnlost() //客户类的解挂函数
{
bool k;
k=Customer::login();
if(k)
{
if(bCus_lost)
{
bCus_lost=false;
cout<<"解挂成功"<<endl;
}
else
cout<<"当前账户无需解挂"<<endl;
}
else
cout<<"密码错误";
}
<img src="https://img-blog.csdn.net/20150718093554910?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /><img src="https://img-blog.csdn.net/20150718093605233?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
<img src="https://img-blog.csdn.net/20150718093613310?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /><img src="https://img-blog.csdn.net/20150718093618831?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
<img src="https://img-blog.csdn.net/20150718093633138?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /><img src="https://img-blog.csdn.net/20150718093639085?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
<img src="https://img-blog.csdn.net/20150718093644447?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /><img src="https://img-blog.csdn.net/20150718093649499?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
<img src="https://img-blog.csdn.net/20150718093654922?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
</pre><pre name="code" class="cpp"><img src="https://img-blog.csdn.net/20150718093623362?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /><img src="https://img-blog.csdn.net/20150718093628413?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />