// 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}."); } } }
// Overrides public override void Create(int account_id) { Balance = TUI.ReadDecimal("Please Enter the initial Balance."); FeeChargedPerTxn = TUI.ReadDecimal("Please Enter the Fee Charged Per Transaction"); base.Create(account_id); }
// overrides public override void Create(int account_id) { Balance = TUI.ReadDecimal("Please Enter the initial Balance."); IntrestRate = TUI.ReadDecimal("Please Enter the intrest Rate"); base.Create(account_id); }
// handles account menu, selecting one account private static void HandleAccount(List <Account> accounts) { bool accountSelected = false; Account account = new Account(); int input; do { if (accountSelected) { DisplayMenu(account); } else { DisplayMenu(); } Console.Title = "Account"; input = TUI.ReadInteger("write your input here: "); Console.Clear(); const string errormsg = "Please select a account first"; // TODO: make functions for each of them switch (input) { // Opens Selection Menu case 1: int account_id = TUI.ReadInteger("please enter your account id you want: "); if (account_id <= RunningAccountNumber) { var query = from _account in accounts where _account.AccountID == account_id select _account; foreach (Account _account in query) { account = _account; } accountSelected = true; } else { Console.WriteLine("Please check your account number again."); } break; // Add Deposit case 2: if (accountSelected) { decimal balance = TUI.ReadDecimal("How much you want to deposit: "); account.Deposit(balance); } else { Console.WriteLine(errormsg); } break; // Widrawl Menu case 3: if (accountSelected) { decimal amount = TUI.ReadDecimal("How much you want to widraw"); account.Widraw(amount); } else { Console.WriteLine(errormsg); } break; // Account Details case 4: if (accountSelected) { Console.WriteLine(account.ToString()); } else { Console.WriteLine(errormsg); } break; // Shows the intrest // NOTE: For Savings Account Only case 5: if (accountSelected) { if (account is SavingsAccount savingsAccount) { Console.WriteLine($"{savingsAccount.CalculateIntrest():C}"); } } else { Console.WriteLine(errormsg); } break; // Displays Loan Menu case 6: if (accountSelected) { HandleLoan(account); } else { Console.WriteLine(errormsg); } break; // The exit case 7: break; // If nothing works default: Console.WriteLine("Woops! That didn't work."); break; } } while (input != 7); }