public void Open(Tepe Tepe, decimal sum, StateAccHand addSumHandler, StateAccHand withdrawSumHandler, StateAccHand calculationHandler, StateAccHand closeAccountHandler, StateAccHand openAccountHandler) { T newAccount = null; switch (Tepe) { case Tepe.Ordinary: newAccount = new DemandAccount(sum, 1) as T; break; case Tepe.Deposit: newAccount = new DepositAccount(sum, 40) as T; break; } if (newAccount == null) { throw new Exception("error open acc"); } 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(); }
private static void VirtualMethods() { var m = new Meteksan() { CompanyName = "Meteksan Holding", ExpiresAt = DateTime.Now.AddYears(1) }; var t = new Tepe() { CompanyName = "Tepe Holding", ExpiresAt = DateTime.Now.AddMonths(6) }; var b = new BA() { CompanyName = "Bilge Adam Yazılım", ExpiresAt = DateTime.Now.AddYears(2) }; PrintTotalWithCommission(m, 10000); PrintTotalWithCommission(t, 10000); PrintTotalWithCommission(b, 10000); }