- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
16_4.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:4k
源码类别:
C#编程
开发平台:
Visual C++
- //16_4.cpp
- #include <iostream.h>
- #include "account.h"
- #include "savings.h"
- #include "checking.h"
- #include "credit.h"
- void DoSavings(int access);
- void DoChecking(int access);
- void DoAccess(int type);
- void DoCredit(int access);
- void main()
- {
- int sele=1;
- while(sele){
- cout <<"nbank managementnn"
- <<"0. Returnn"
- <<"1. Savings businessn"
- <<"2. Checking businessn"
- <<"3. Credit businessnn"
- <<"select : ";
- cin >>sele;
- if(sele>=1 && sele <=3) DoAccess(sele);
- }
- Account* p=Account::First(); //以下善后
- while(p){
- Account* t=p;
- p=p->Next();
- delete t;
- }
- Account::First()=NULL;
- }
- void DoAccess(int type)
- {
- int sele=1;
- while(sele){
- cout <<"nFetching or savingnn"
- <<"0. Returnn"
- <<"1. Fetchingn"
- <<"2. Savingnn"
- <<"select : ";
- cin >>sele;
- if(sele!=1 && sele!=2) continue;
- switch(type){
- case 1: DoSavings(sele); break;
- case 2: DoChecking(sele); break;
- case 3: DoCredit(sele); break;
- }
- }
- }
- void DoSavings(int access)
- {
- unsigned aN;
- float val;
- if(access==2){ //saving
- cout <<"nplease input some account and amount for saving(input 0 for end):n";
- cin >>aN >>val;
- while(aN && val>0){
- Account* p;
- for(p=Account::First(); p; p=p->Next()) //finding
- if(p->AccountNo()==aN && dynamic_cast<Savings*>(p)){
- p->Deposit(val);
- break;
- }
- if(!p) //not found
- new Savings(aN,val);
- cout <<"nplease input some account and amount for saving(input 0 for end):n";
- cin >>aN >>val;
- }
- }else{ //fetching
- cout <<"please input a account number and amount for fetching(input 0 for end):n";
- cin >>aN >>val;
- while(aN && val>0){
- Account* p;
- for(p=Account::First(); p; p=p->Next()) //finding
- if(p->AccountNo()==aN && dynamic_cast<Savings*>(p)){
- p->Withdrawal(val);
- break;
- }
- if(!p)
- cout <<"error: the account number isn't found.n";
- cout <<"nplease input a account number and amount for fetching(input 0 for end):n";
- cin >>aN >>val;
- }
- }
- }
- void DoChecking(int access)
- {
- unsigned aN;
- float val;
- if(access==2){ //saving
- cout <<"nplease input some account and amount for saving(input 0 for end):n";
- cin >>aN >>val;
- while(aN && val>0){
- Account* p;
- for(p=Account::First(); p; p=p->Next()) //finding
- if(p->AccountNo()==aN && dynamic_cast<Checking*>(p)){
- p->Deposit(val);
- break;
- }
- if(!p) //not found
- new Checking(aN,val);
- cout <<"nplease input some account and amount for saving(input 0 for end):n";
- cin >>aN >>val;
- }
- }else{ //fetching
- cout <<"nplease input a account number and amount for fetching(input 0 for end):n";
- cin >>aN >>val;
- while(aN && val>0){
- Account* p;
- for(p=Account::First(); p; p=p->Next()) //finding
- if(p->AccountNo()==aN && dynamic_cast<Checking*>(p)){
- p->Withdrawal(val);
- break;
- }
- if(!p)
- cout <<"error: the account number isn't found.n";
- cout <<"nplease input a account number and amount for fetching(input 0 for end):n";
- cin >>aN >>val;
- }
- }
- }
- void DoCredit(int access)
- {
- unsigned aN;
- float val;
- if(access==2){ //saving
- cout <<"please input some account and amount for saving(input 0 for end):n";
- cin >>aN >>val;
- while(aN && val>0){
- Account* p;
- for(p=Account::First(); p; p=p->Next()) //finding
- if(p->AccountNo()==aN && dynamic_cast<Creditcard*>(p)){
- p->Deposit(val);
- break;
- }
- if(!p) //not found
- new Creditcard(aN,val);
- cout <<"nplease input some account and amount for saving(input 0 for end):n";
- cin >>aN >>val;
- }
- }else{ //fetching
- cout <<"nplease input a account number and amount for fetching(input 0 for end):n";
- cin >>aN >>val;
- while(aN && val>0){
- Account* p;
- for(p=Account::First(); p; p=p->Next()) //finding
- if(p->AccountNo()==aN && dynamic_cast<Creditcard*>(p)){
- p->Withdrawal(val);
- break;
- }
- if(!p)
- cout <<"error: the account number isn't found.n";
- cout <<"nplease input a account number and amount for fetching(input 0 for end):n";
- cin >>aN >>val;
- }
- }
- }