public static IAccount AddAccount<TAccount>() where TAccount : IAccount { ConsoleUtil.Display(Properties.Resources.WhatAccountType); IAccount a; switch (ConsoleUtil.GetResponse(ListAccountTypes<TAccount>())) { case "checking": a = new CheckingAccount(nextAccountId++); break; case "business": a = new BusinessAccount(nextAccountId++); break; case "loan": ConsoleUtil.WriteLine(Properties.Resources.WhatSizeLoan); a = new Loan(nextAccountId++, ConsoleUtil.GetDollarAmount()); break; case "cd": ConsoleUtil.WriteLine(Properties.Resources.WhatSizeCD); a = new TermDeposit(nextAccountId++, ConsoleUtil.GetDollarAmount()); break; default: Log.Error(Properties.Resources.ErrorInvalidProgramFlow); throw new Exception("Bank: Invalid program flow."); } ConsoleUtil.WriteLine(Properties.Resources.GiveAccountName); var name = ConsoleUtil.GetString(); while (currentCustomer.HasAccount(name)) { ConsoleUtil.Display(Properties.Resources.AccountNameUnavailable); name = ConsoleUtil.GetString(); } a.Name = name; currentCustomer.AddAccount(a); return a; }
private static void OpenTermDeposit() { Console.Clear(); decimal amount; int years; var del = new ScreenDelegate(OpenTermDeposit); Console.WriteLine("How much would you like to deposit?"); var input = Console.ReadLine(); VerifyAmount(input, out amount, del); Console.WriteLine("How long do want your term to be(years)?"); input = Console.ReadLine(); IntegerNumberVerifier(input, out years, del); VerifyYear(years, del); var account = new TermDeposit() { AccountNumber = _TermDepositID, Balance = amount, Term = years, Maturity = DateTime.Now.AddYears(years), isActive = true, InterestRate = 0.10, CustomerID = _CurrentCustomer.ID, Transactions = new List <Transaction>(), }; account.Deposit(amount); _CurrentCustomer.Accounts.Add(account); var tran = new Transaction() { TransactionID = _TransactionID, TypeOfTransaction = "Deposit", Amount = amount, TimeOfTransaction = DateTime.Now, AccountNumber = _TermDepositID }; AccountSelector(_TermDepositID).Transactions.Add(tran); _TermDepositID++; Console.WriteLine($"You have created a new CD which will mature on {account.Maturity}"); Console.WriteLine("Press enter to go back home"); Console.ReadLine(); CustomerHomeScreen(); }
public void CreateTermDeposit() { Random r = new Random(); var termDeposit = new TermDeposit(); termDeposit.TermDepositID = r.Next(); Console.WriteLine("Please insert the amount you want to deposit?"); decimal amount = decimal.Parse(Console.ReadLine()); if (amount < 0) { Console.WriteLine("We dont accept negative amount!"); } else { termDeposit.AccountBalance += amount; termDeposit._time = DateTime.Now; Console.WriteLine($"Temporary Deposit ID: {termDeposit.TermDepositID} | Amount on balance: ${termDeposit.AccountBalance} | Time of depositing: {termDeposit._time}"); } }