1个回答
展开全部
class AccountManager
{
public:
AccountManager( int _size ){
size = 0;
bankList = new (Bank*)[_size];
if( bankList ){
size = _size;
memset( (void*)bankList, 0 , size*sizeof(Bank*) );
}
}
~AccountManager(){
if( bankList ){
delete[] bankList;
}
}
public:
void setBank(int i, Bank* bank){
if( i < size ){
bankList[i]=bank;
}
}
Bank* getBank(int i){
if( i < size ){
return bankList[i];
}
return 0;
}
void deposit( Bank* bank, double money ){
if( ! bank ){
bank->deposit(money);
}
}
void withdraw(Bank* bank, double money){
if( ! bank ){
bank->withdraw(money);
}
}
void transfer(Bank* bank1, Bank* bank2, double money){
if( ! bank1 && ! bank2 ){
bank1->deposit( money );
bank2->withdraw( money );
}
}
void printAccount() const{
for( int i = 0; i < size; ++i ){
bankList[i]->printMessage();
}
}
private:
Bank** bankList;
int size;
};
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询