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
|
account* factory(std::string account_code, std::string first_name,
std::string last_name, char type, double balance)
{
try
{
if(type == 'A')
{
simple_account *a = new simple_account(account_code, first_name, last_name, balance);
return a;
}
else if(type == 'B')
{
bonus_account *a = new bonus_account(account_code, first_name, last_name, balance);
return a;
}
else if(type == 'C')
{
service_account *a = new service_account(account_code, first_name, last_name, balance);
return a;
}
else if(type == 'D')
{
service_account *a = new service_account(account_code, first_name, last_name, balance);
return a;
}
else{
throw myexception("Invalid account", 1);}
account* a = nullptr;
return a;
}
catch(myexception& e) {std::cerr<< e.get_description() << ": "<< e.get_code()<< std::endl;};
};
|