//account's opening //result: addidtion of a new account to the list of existing accounts public void Open(AccountType accountType, decimal sum, float percentage, AccountStateHandler openStateHandler, AccountStateHandler closeStateHandler, AccountStateHandler receiveStateHandler, AccountStateHandler withdrawStateHandler, AccountStateHandler percentageStateHandler, AccountStateHandler showInfoStateHandler, int period = 0) { T newAccount = default(T); switch (accountType) { case AccountType.Demand: newAccount = new DemandAccount(sum, percentage) as T; break; case AccountType.Deposit: newAccount = new DepositAccount(sum, percentage, period) as T; break; default: throw new Exception("Error while creating account"); } newAccount.Opened += openStateHandler; newAccount.Closed += closeStateHandler; newAccount.Received += receiveStateHandler; newAccount.Withdrawed += withdrawStateHandler; newAccount.InfoShowing += showInfoStateHandler; accounts.Add(newAccount); }
// метод создания счета public void Open(AccountType accountType, decimal sum, AccountStateHandler addSumHandler, AccountStateHandler withdrawSumHandler, AccountStateHandler calculationHandler, AccountStateHandler closeAccountHandler, AccountStateHandler openAccountHandler) { T newAccount = null; switch (accountType) { // Тип аккаунта case AccountType.Ordinary: newAccount = new DemandAccount(sum, 0, AccountType.Ordinary) as T; break; case AccountType.Deposit: newAccount = new DepositAccount(sum, 12, AccountType.Deposit) as T; break; } if (newAccount == null) { throw new Exception("Ошибка создания счета"); } // добавляем новый счет в массив счетов if (accounts == null) { accounts = new T[] { newAccount } } ; else { T[] tempAccounts = new T[accounts.Length + 1]; for (int i = 0; i < accounts.Length; i++) { tempAccounts[i] = accounts[i]; } tempAccounts[tempAccounts.Length - 1] = newAccount; accounts = tempAccounts; } // установка обработчиков событий счета newAccount.Added += addSumHandler; newAccount.Withdrawed += withdrawSumHandler; newAccount.Closed += closeAccountHandler; newAccount.Opened += openAccountHandler; newAccount.Calculated += calculationHandler; newAccount.Open(); }
// ----------------------------------------- // create account // ----------------------------------------- // with type and start sum public void Open(AccountType accountType, decimal sum) { T newAccount = null; switch (accountType) { // Тип аккаунта case AccountType.Ordinary: newAccount = new DemandAccount(sum, 0, AccountType.Ordinary) as T; break; case AccountType.Deposit: newAccount = new DepositAccount(sum, DEPOSIT_PERCENTAGE, AccountType.Deposit, _date) as T; break; } if (newAccount == null) { throw new Exception("Ошибка создания счета"); } // добавляем новый счет в массив счетов if (accounts == null) { accounts = new T[] { newAccount } } ; else { T[] tempAccounts = new T[accounts.Length + 1]; for (int i = 0; i < accounts.Length; i++) { tempAccounts[i] = accounts[i]; } tempAccounts[tempAccounts.Length - 1] = newAccount; accounts = tempAccounts; } newAccount.Added += Added; newAccount.Withdrawed += Withdrawed; newAccount.Closed += Closed; newAccount.Opened += Opened; newAccount.OpenedNewAccEvent += OpenedNewAccEvent; newAccount.CloseAccEvent += CloseAccEvent; newAccount.UpdateValueAccEvent += UpdateValueAccEvent; newAccount.Open(); }
public void Open(AccountType accountType, decimal sum, AccountStateHandler addSumHandler, AccountStateHandler withdarwSumHandler, AccountStateHandler calculationHandler, AccountStateHandler closeAccountHandler, AccountStateHandler openAccountHandler) { T newAccount = null; switch (accountType) { case AccountType.Ordinary: newAccount = new DemandAccount(sum, 1) as T; break; case AccountType.Deposit: newAccount = new DepositAccount(sum, 40) as T; break; } if (newAccount == null) { throw new Exception("Error creating"); } if (accounts == null) { accounts = new T[] { newAccount } } ; else { T[] tempAccounts = new T[accounts.Length + 1]; for (int i = 0; i < accounts.Length; i++) { tempAccounts[i] = accounts[i]; } tempAccounts[tempAccounts.Length - 1] = newAccount; accounts = tempAccounts; } newAccount.Added += addSumHandler; newAccount.Whithdrawed += withdarwSumHandler; newAccount.Closed += closeAccountHandler; newAccount.Opened += openAccountHandler; newAccount.Calculated += calculationHandler; newAccount.Open(); }