/// <summary> /// Method for adding new account into Account repository /// </summary> /// <param name="client">Owner of account</param> /// <param name="startAmount">Value of start amount</param> public void Create(Client client, decimal startAmount) { if (startAmount >= 0m && startAmount < 1000m) { var account = new BaseBankAccount(client, startAmount); bankAccounts.Add(account); } else if (startAmount >= 1000m && startAmount < 5000m) { var account = new SilverBankAccount(client, startAmount); bankAccounts.Add(account); } else if (startAmount >= 5000m && startAmount < 10000m) { var account = new GoldBankAccount(client, startAmount); bankAccounts.Add(account); } else if (startAmount >= 10000m) { var account = new PlatinumBankAccount(client, startAmount); bankAccounts.Add(account); } }
public static void Main(string[] args) { BaseBankAccount firstBankAccount = new BaseBankAccount(1234, "Vinnichek Ira"); GoldBankAccount secondBankAccount = new GoldBankAccount(3456, "Petrov Petya"); PlatinumBankAccount thirdBankAccount = new PlatinumBankAccount(4567, "Ivanov Ivan"); PlatinumBankAccount fourthBankAccount = new PlatinumBankAccount(4567, "Ivanov Ivan"); Console.WriteLine(firstBankAccount); Console.WriteLine(firstBankAccount.Equals(secondBankAccount)); //false Console.WriteLine(thirdBankAccount.Equals(fourthBankAccount)); //true firstBankAccount.ReplenishBalance(1000); secondBankAccount.ReplenishBalance(1000); thirdBankAccount.ReplenishBalance(1000); thirdBankAccount.WithdrawMoney(200); BankAccountService service = new BankAccountService(); service.AddBankAccount(firstBankAccount); service.AddBankAccount(secondBankAccount); Console.WriteLine(service); service.RemoveBankAccount(secondBankAccount); Console.WriteLine(service); service.AddBankAccount(secondBankAccount); service.AddBankAccount(thirdBankAccount); Console.WriteLine("\r\n"); Console.WriteLine("------List of bank accounts.------"); Console.WriteLine(service); IBankAccountStorage binaryStorage = new BankAccountBinaryStorage(@"/Users/vinnichek/Projects/Task/ConsoleAppForBankAccount/BankAccounts.txt"); //service.SaveToStorage(binaryStorage); //service.LoadFromStorage(binaryStorage); }