16_3.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:2k
源码类别:
C#编程
开发平台:
Visual C++
- //16_3
- #include <iostream.h>
- #include "account.h"
- #include "savings.h"
- #include "checking.h"
- void DoSavings(int n);
- void DoChecking(int n);
- void DoAccess(int n);
- void main()
- {
- int sele;
- while(1){
- cout <<"bank managementnn"
- <<"0. Returnn"
- <<"1. Savings businessn"
- <<"2. Checking businessnn"
- <<"select : ";
- cin >>sele;
- if(sele==1||sele==2)
- DoAccess(sele);
- if(sele==0)
- break;
- }
- //sanhou
- for(Account* p=Account::First(); p; ){
- Account* t=p;
- p=p->Next();
- delete t;
- }
- Account::First()=NULL;
- }
- void DoAccess(int s)
- {
- int sele=0;
- while(1){
- cout <<"Fetching or savingnn"
- <<"0. Returnn"
- <<"1. Fetchingn"
- <<"2. Savingnn"
- <<"select : ";
- cin >>sele;
- if(sele==1||sele==2)
- if(s==1)
- DoSavings(sele);
- else
- DoChecking(sele);
- if(sele==0)
- break;
- }
- //sanhou
- }
- void DoSavings(int n)
- {
- unsigned aN;
- float val;
- if(n==2){ //saving
- cout <<"please input some account and checking:n";
- cin >>aN >>val;
- while(aN){
- new Savings(aN,val);
- cout <<"please input some account and checking:n";
- cin >>aN >>val;
- }
- }else{
- cout <<"please input a account number:n";
- cin >>aN;
- while(aN){
- for(Account* p=Account::First(); p; p=p->Next())
- if(p->AccountNo()==aN && dynamic_cast<Savings*>(p)){
- cout <<"Savings Account: "<<p->AccountNo()
- <<" " <<p->AcntBalan() <<endl;
- break;
- }
- cout <<"please input a account number:n";
- cin >>aN;
- }
- }
- }
- void DoChecking(int n)
- {
- unsigned aN;
- float val;
- if(n==2){ //checking
- cout <<"please input some account and checking:n";
- cin >>aN >>val;
- while(aN){
- new Checking(aN,val);
- cout <<"please input some account and checking:n";
- cin >>aN >>val;
- }
- }else{
- cout <<"please input a account number:n";
- cin >>aN;
- while(aN){
- for(Account* p=Account::First(); p; p=p->Next())
- if(p->AccountNo()==aN && dynamic_cast<Checking*>(p)){
- cout <<p->AccountNo() <<" " <<p->AcntBalan() <<endl;
- break;
- }
- cout <<"please input a account number:n";
- cin >>aN;
- }
- }
- }