/// <inheritdoc/> public void OpenAccount(string name, AccountType accountType, IAccountBonus bonusType, IAccountNumberCreateService createService) { BankAccount newAccount = null; int id = createService.CreateId(); while (this.Accounts.Any(a => a.AccountNumber == id)) { id = createService.CreateId(); } switch (accountType) { case AccountType.Base: newAccount = new BaseBankAccount(id, name, bonusType); break; case AccountType.Silver: newAccount = new SilverBankAccount(id, name, bonusType); break; case AccountType.Gold: newAccount = new GoldBankAccount(id, name, bonusType); break; } this.Accounts.Add(newAccount); this.SaveAccountsToStorage(); }