Bank.h
上传用户:sz0451
上传日期:2022-07-29
资源大小:256k
文件大小:1k
- #pragma once
- #include "Account.h"
- #using <mscorlib.dll>
- using namespace System::Collections;
- __gc class Bank
- {
- public:
- Bank(void);
- private:
- ArrayList* accts;
- public:
- bool Add(Account* pAcc)
- {
- // check if account is in list
- if (accts->Contains(pAcc))
- return false;
- else
- accts->Add(pAcc);
- return true;
- }
- bool Remove(Account* pAcc)
- {
- // check if account is in list
- if (accts->Contains(pAcc))
- {
- accts->Remove(pAcc);
- return true;
- }
- else
- return false;
- }
- __property Account* get_Acct(long number)
- {
- IEnumerator* ie = accts->GetEnumerator();
- while (ie->MoveNext())
- {
- Account* pa = dynamic_cast<Account*>(ie->get_Current());
- if (pa->AccountNumber == number)
- return pa;
- }
- throw new ArgumentOutOfRangeException("Bad account number");
- }
- };