C++课程设计报告(含源码)模拟ATM机.doc_第1页
C++课程设计报告(含源码)模拟ATM机.doc_第2页
C++课程设计报告(含源码)模拟ATM机.doc_第3页
C++课程设计报告(含源码)模拟ATM机.doc_第4页
C++课程设计报告(含源码)模拟ATM机.doc_第5页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

C+课程设计*课题:简单银行系统模拟ATM系别:计科系专业年级:XXXXXX学号:XXXXX姓名:XXXX一、 设计任务分析根据课程设计要求及个人具体情况,分析如下:系统具有注册开户、用户登录、退出功能。注册开户中有身份证号码、姓名、地址、电话号码、货币类型、预存金额。用户登录中,用户登录成功后,才能享受取款、存款、修改密码等服务。二、 类(对象)设计据上得,设计类AccountItem和Accountbook。其类图如下:AccountItemstring m_Anumber;string m_Password;string m_Name;double m_Balance;string m_Adress; string m_ID;string m_TEL;string m_Currency;AccountItem(AccountItem &a);AccountItem &operator=(AccountItem &a);AccountItem();AccountItem(string number,string password,string name,double balance,string Currency,string TEL,string ID,string Adress);void Display();void write(ofstream &out);void read(ifstream& cin);int CheckNumber(string Anumber);string GetNumber();string GetPassword();void UpdatePassword(string password);void DeductBalance(double pay);void StoreBalance(double money);double GetBalance();string GetName();int IsNull();AccountbookAccountItem b100; int m_AccountCount;void SetAccountbook();Accountbook(); void LoadAccountbook();void StoreAccountbook(); AccountItem FindItem(string number);bool UpdateItem(AccountItem Item);三、 流程图ATM退出用户登录注册开户取款存款修改密码退出账号密码姓名身份证号住址电话货币类型预存金额OK四、源代码#include #include #include using namespace std;class AccountItemprivate:string m_Anumber;string m_Password;string m_Name;double m_Balance;string m_Adress; string m_ID;string m_TEL;string m_Currency;public:AccountItem(AccountItem &a) m_Anumber=a.m_Anumber; m_Password=a.m_Password;m_Name=a.m_Name; m_Balance=a.m_Balance; m_Currency=a.m_Currency; m_TEL=a.m_TEL; m_ID=a.m_ID; m_Adress=a.m_Adress;AccountItem &operator=(AccountItem &a) m_Anumber=a.m_Anumber; m_Password=a.m_Password; m_Name=a.m_Name; m_Balance=a.m_Balance; m_Currency=a.m_Currency; m_TEL=a.m_TEL; m_ID=a.m_ID; m_Adress=a.m_Adress; return *this;void SetAccountItem(string number,string password,string name,double balance,string Currency,string TEL,string ID,string Adress); AccountItem();AccountItem(string number,string password,string name,double balance,string Currency,string TEL,string ID,string Adress);void Display();void write(ofstream &out);void read(ifstream& cin);int CheckNumber(string Anumber);string GetNumber();string GetPassword();void UpdatePassword(string password);void DeductBalance(double pay);void StoreBalance(double money);double GetBalance();string GetName();int IsNull();void AccountItem:SetAccountItem(string number,string password,string name,double balance,string Currency,string TEL,string ID,string Adress)m_Anumber=number;m_Password=password;m_Name=name;m_Balance=balance;m_Currency=Currency; m_TEL=TEL; m_ID=ID; m_Adress=Adress;void AccountItem:UpdatePassword(string password) m_Password=password;void AccountItem:StoreBalance(double money)m_Balance=m_Balance+money;int AccountItem:CheckNumber(string Anumber)if(m_Anumber=Anumber)return 1;elsereturn 0;string AccountItem:GetNumber()return m_Anumber;string AccountItem:GetPassword()return m_Password;void AccountItem:DeductBalance(double pay)m_Balance=m_Balance-pay;double AccountItem:GetBalance()return m_Balance;string AccountItem:GetName()return m_Name;int AccountItem:IsNull()if(m_Anumber=)return 1;return 0;void AccountItem:read(ifstream& cin) cinm_ID;cinm_Name;cinm_Adress;cinm_TEL; cinm_Currency;cinm_Balance;cinm_Anumber;cinm_Password;void AccountItem:write(ofstream &cout) coutm_IDendl;coutm_Nameendl;coutm_Adressendl;coutm_TELendl; coutm_Currencyendl;coutm_Balanceendl;coutm_Anumberendl;coutm_Passwordendl;AccountItem:AccountItem()m_Anumber=;m_Password=;m_Name=;m_Balance=0;m_Currency=;m_TEL=;m_ID=;m_Adress=;AccountItem:AccountItem(string number,string password,string name,double balance,string Currency,string TEL,string ID,string Adress)m_Anumber=number;m_Password=password;m_Name=name;m_Balance=balance;m_Currency=Currency; m_TEL=TEL; m_ID=ID; m_Adress=Adress;void AccountItem:Display()cout账号:;coutm_Anumberendl;cout密码:;coutm_Passwordendl;cout姓名:;coutm_Nameendl;cout存款余额:;coutm_Balanceendl;class Accountbookprivate: AccountItem b100; int m_AccountCount;public: void SetAccountbook();Accountbook(); void LoadAccountbook();void StoreAccountbook(); AccountItem FindItem(string number); bool UpdateItem(AccountItem Item);void Accountbook:SetAccountbook()string AccountNo;string AccountPassword;string ItemName;double Balance;string Currency;string TEL;string ID;string Adress;string password1,password2;ofstream Output(accountbook.txt);coutAccountNo;coutpassword1;cout请输入确认密码:password2;if(password1=password2) AccountPassword=password1;break;elsecout密码和确认密码不同!请重新输入:endl;coutItemName;coutID; coutAdress;coutTEL;int i;while(1)cout请选择货币种类:endl;cout1.人民币 2.美元i;if(i=1)Currency=人民币;coutBalance;break;else if(i=2)Currency=美元;coutBalance;Balance=Balance*8;break;else cout选择类型错误!endl;continue; bm_AccountCount.SetAccountItem(AccountNo,AccountPassword,ItemName,Balance, Currency,TEL,ID,Adress); m_AccountCount+;for(int j=0;jm_AccountCount;j+)bj.write(Output);Accountbook:Accountbook() m_AccountCount=0;void Accountbook:LoadAccountbook( ) ifstream Input(accountbook.txt);int j=0; while(Input) bj.read(Input); j+; Input.close();m_AccountCount=j;return;AccountItem Accountbook:FindItem(string number)int i;bool Found=false;for(i=0;im_AccountCount;i+)if(bi.GetNumber()=number)Found=true;break;if(Found=true)return bi;elsereturn AccountItem();bool Accountbook:UpdateItem(AccountItem Item)string no=Item.GetNumber();int i;bool flag=false;for(i=0;im_AccountCount;i+)if(bi.GetNumber()=no)flag=true;break;if(flag=true)bi=Item; return flag;void Accountbook:StoreAccountbook()ofstream Output(accountbook.txt);int k;for(k=0;km_AccountCount;k+)bk.write(Output);Output.close();return;class Massageprivate: Accountbook MyAccountbook; AccountItem FindItem;public:Massage()void MakeMassage();void Massage:MakeMassage()ifstream Input(accountbook.txt);int n;string AccountNo;string AccountPassword;double AccountPay;string ItemName;double Balance;string TransactionCode;coutendl; docout n n 欢迎使用银行管理系统 模拟ATM机 n n 请用户在使用前选择开户: n 1:注册开户 n 2:用户登录 n 0:退出 n n n nendl;cout请选择:n;switch(n)case 1: MyAccountbook.SetAccountbook(); break;case 2:MyAccountbook.LoadAccountbook( ); coutAccountNo;FindItem=MyAccountbook.FindItem(AccountNo); if(FindItem.IsNull() cout此用户不存在!endl; return; coutAccountPassword; if(FindItem.GetPassword()!=AccountPassword) cout密码错误!endl; return; int m;do cout1:取款n 2:存款n3:查询余额n4:修改密码n0:退出nm; switch(m) case 2: coutAccountPay; FindItem.StoreBalance(AccountPay); MyAccountbook.UpdateItem(FindItem); MyAccountbook.StoreAccountbook(); break; case 1: coutAccountPay; FindItem.DeductBalance(AccountPay);MyAccount

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论