// Creates Accounts private static void Createaccounts(List <Account> accounts) { // The total number of accounts to be created int NumberOfAccounts = TUI.ReadInteger("How many Accounts would you like to create? "); // the creation Loop for (int i = 0; i < NumberOfAccounts; i++) { Console.WriteLine($"Account number - {++RunningAccountNumber}"); Console.WriteLine("Which account Would You Like to create?: "); Console.WriteLine("1. Savings Account"); Console.WriteLine("2. Checking Account"); int input = TUI.ReadIntegerRange(1, 2); Account account = null; // creates account according to the type switch (input) { case 1: account = new SavingsAccount(); break; case 2: account = new CheckingAccount(); break; } account.Create(RunningAccountNumber); accounts.Add(account); } }
// Processes The loan // returns the status after processsing public void Process(Account account) { { bool result = false; string reason = ""; // Checks if the account already has a loan. if (!account.HasLoan) { // Verification Check if (!(TUI.ReadInteger("Please Enter Your unique accountID for verification: ") == account.AccountID)) { reason = "Verification Error"; } else { // Checks the initial Balance Before Giving Loan. if (account.Balance > Amount) { // Asks For all the details Amount = TUI.ReadDecimal("Please Enter What amount of loan would you like : "); Days = TUI.ReadInteger("For How many Days: "); Rate = TUI.ReadInteger("The intrest rate from the chart: "); Installments = TUI.ReadIntegerRange(3, 10, "How many installments would you like? (3-10): "); AmountPerInstallment = ((Rate * Days) + Amount) / Installments; account.Balance += Amount; account.HasLoan = true; DateIssued = DateTime.Now; InstallmentsLeft = Installments; LateCharge = TUI.ReadDecimal("Please Enter the Late Charge displayed on the chart."); Console.WriteLine("Loan Successfully Initiated!"); Console.WriteLine($"This is your balance now {account.Balance:C}"); Console.WriteLine($"The Loan is due on: {DateExpire.ToShortDateString()}"); result = true; } else { reason = "Low Balance"; Console.WriteLine($"This is your balance {account.Balance:C}"); Console.WriteLine($"This is your amount {Amount:C}"); } } } else { reason = "Loan Already Issued"; } if (!(result && reason == "")) { Console.WriteLine($"Loan Couldn't be processed please try again, reason: {reason}."); } } }