1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include<fstream>
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include"account.h"
#include"accountInfo.h"
#include "exceptionHandling.h"
#include"balancedAccount.h"
#include"serviceAccount.h"
#include"bonusAccount.h"
#include"simpleAccount.h"
using namespace exception_handling;
using namespace std;
using namespace account_info;
using account_class::account;
using balanced_account::balancedAccount;
using service_account::serviceAccount;
using bonus_account::bonusAccount;
using simple_account::simpleAccount;
void outputTest(char e, string a, string b, string c, double d){
cout << e << " ,"<< a <<" ,"<< b <<" ,"<< c <<" ,"<< d <<'\n';
}
class factoryFunction{
private:
string first;
string last;
string accountCode;
double balance;
char type;
public:
account* inputAccounts(istream& s){
for(int i=1; i<2; ++i){
try{
accountCode = get_accountCode(s, 10);
first = get_info(s, 15);
last = get_info(s, 25);
type = s.get();
s >> balance;
if(s.peek()!='\n'){
throw input_error_exception();
}
s.ignore();
outputTest(type, accountCode, last, first, balance);
if(type == 'A'||type == 'B'||type == 'C'||type == 'D'){
switch(type){
case 1:
if (type == 'A'){
return new simpleAccount(accountCode, first, last, balance);
}
case 2:
if (type == 'B'){
return new bonusAccount(accountCode, first, last, balance);
}
case 3:
if (type == 'C'){
return new serviceAccount(accountCode, first, last, balance);
}
case 4:
if (type == 'D'){
return new balancedAccount(accountCode, first, last, balance);
}
case 5:
if (type == 'X'){
--i;
}
}
}else{
throw invalid_account_type_exception(accountCode, type);
}
}catch(input_error_exception& three){ cout<< "Error 2203: ", three.what();
}catch(invalid_account_type_exception& invalid){ cout << "Error 2205: \n"; invalid.invalid_account(); --i;}
}
return '\0';
}
};
|