public void makeTransactionFromSavingAccount(string accountNo = "") { if (accountNo == "") { InputOutputHandler IO_Handler = new InputOutputHandler(); accountNo = IO_Handler.getAccountNoFromUser(); } int indexOfSavingAccountInADT = this.getSavingAccountIndex(accountNo); if (indexOfSavingAccountInADT != -1) { SavingAccount savingAccountToMakeTransactionOn = accountsData.AllSavingAccountsList[indexOfSavingAccountInADT] as SavingAccount; double withdrawAmount = IO_Handler.getAmountToWithdrawFromUser(savingAccountToMakeTransactionOn.Balance, savingAccountToMakeTransactionOn.Balance); if (!isTransactionsThresholdMetForAnAccount(savingAccountToMakeTransactionOn.AccountNo, withdrawAmount)) { (accountsData.AllSavingAccountsList[indexOfSavingAccountInADT] as SavingAccount).withdrawal(withdrawAmount); Transaction transaction = new Transaction(savingAccountToMakeTransactionOn.AccountNo, withdrawAmount, 'S', DateTime.Now); accountsData.AllTransations.Add(transaction); accountsData.generateTransactionReport(transaction, (accountsData.AllSavingAccountsList[indexOfSavingAccountInADT] as SavingAccount).Balance); } else { IO_Handler.cantWithdrawToday(withdrawAmount); } } else { IO_Handler.printNotFoundSavingAccount(accountNo); } }
public void addASavingAccount() { SavingAccount newSavingAccountCreated = IO_Handler.getSavingAccountDetailsFromUser(); accountsData.AllSavingAccountsList.Add(newSavingAccountCreated); if (IO_Handler.wantAnAtm()) { string pin = IO_Handler.getAtmPinFromUser(); accountsData.AllAtmCards.Add(new Atm(newSavingAccountCreated.AccountNo, pin)); } }
// Update menus public SavingAccount printUpdateSavingAccountMenu(SavingAccount accountToUpdate) { Console.WriteLine("##### Account Info #####\n"); this.printOneSavingAccount(accountToUpdate); Console.WriteLine("Press 1 to update Account No"); Console.WriteLine("Press 2 to update Account Title"); Console.WriteLine("Press 3 to update Cnic"); Console.WriteLine("Press 4 to update Balance"); Console.WriteLine("Press 5 to update Withdrawal Limit"); Console.WriteLine("Press 0 to Exit"); Console.Write("Your Choice : "); char choice = Console.ReadLine()[0]; while (!(choice >= '0' && choice <= '5')) { Console.Write("Re-enter your choice between 0 and 5 : "); choice = Console.ReadLine()[0]; } switch (choice) { case '1': Console.Write("Enter new account no : "); accountToUpdate.AccountNo = Console.ReadLine(); break; case '2': Console.Write("Enter new title : "); accountToUpdate.AccountTitle = Console.ReadLine(); break; case '3': Console.Write("Enter new Cnic : "); accountToUpdate.Cnic = Console.ReadLine(); break; case '4': Console.Write("Enter new balance : "); accountToUpdate.Balance = double.Parse(Console.ReadLine()); break; case '5': Console.Write("Enter new profit percentage : "); accountToUpdate.ProfitPercentage = double.Parse(Console.ReadLine()); break; default: Console.WriteLine("No changes have been made!"); break; }; return accountToUpdate; }
public void updateSavingAccount() { string accountNoToUpdateItsDetails = IO_Handler.getAccountNoFromUser(); int indexOfSavingAccountToUpdate = getCurrentAccountIndex(accountNoToUpdateItsDetails); if (indexOfSavingAccountToUpdate != -1) { SavingAccount accountToUpdate = accountsData.AllSavingAccountsList[indexOfSavingAccountToUpdate] as SavingAccount; accountsData.AllSavingAccountsList[indexOfSavingAccountToUpdate] = IO_Handler.printUpdateSavingAccountMenu(accountToUpdate); } else { IO_Handler.printNotFoundSavingAccount(accountNoToUpdateItsDetails); } }
// Interface for user public void printAccountHolderInterface() { AccountManager userInteracting = new AccountManager(); string accountNo = this.getAccountNoFromUser(); string pin = ""; if (this.selectAccountType() =='c') { if (userInteracting.getCurrentAccountIndex(accountNo) == -1) { Console.WriteLine("Current Account with AccountNo '" + accountNo + "' does not exist"); Environment.Exit(0); } if (!userInteracting.hasAtm(accountNo)) { Console.WriteLine("You dont an atm card registered"); Console.Write("Register for ATM now (y/n) : "); char choice = Console.ReadLine()[0]; if (choice == 'y' || choice == 'Y') { pin = this.getAtmPinFromUser(); userInteracting.AccountsData.AllAtmCards.Add(new Atm(accountNo, pin)); } else { Console.WriteLine("Bye! Come back when you want or have an atm card"); Environment.Exit(0); } } CurrentAccount accountInfoOfTheUserWhoLoggedIn = userInteracting.AccountsData.AllCurrentAccountsArrayList[userInteracting.getCurrentAccountIndex(accountNo)] as CurrentAccount; do { Console.Clear(); Console.WriteLine("##### My Virtual Bank #####"); Console.WriteLine("Press 0 to exit"); Console.WriteLine("Press 1 to display account info"); Console.WriteLine("Press 2 to deposit an amount"); Console.WriteLine("Press 3 to withdraw an amount"); Console.Write("\nEnter your choice : "); char choice = Console.ReadLine()[0]; switch (choice) { case '0': userInteracting.writeBackAllFiles(); Environment.Exit(0); break; case '1': this.printOneCurrentAccount(accountInfoOfTheUserWhoLoggedIn); break; case '2': pin = this.getAtmPinFromUser(); if (userInteracting.verifyCredentials(accountInfoOfTheUserWhoLoggedIn.AccountNo, pin)) { userInteracting.makeDepositToCurrentAccount(accountNo); } else { Console.WriteLine("You entered incorrect pin"); } break; case '3': pin = this.getAtmPinFromUser(); if (userInteracting.verifyCredentials(accountInfoOfTheUserWhoLoggedIn.AccountNo, pin)) { userInteracting.makeTransactionFromCurrentAccount(accountNo); } else { Console.WriteLine("You entered incorrect pin"); } break; default: break; } } while (askIfUserWantsToContinue()); } else { if(userInteracting.getSavingAccountIndex(accountNo) == -1) { Console.WriteLine("Saving Account with AccountNo '" + accountNo + "' does not exist"); Environment.Exit(0); } if (!userInteracting.hasAtm(accountNo)) { Console.WriteLine("You dont an atm card registered"); Console.Write("Register for ATM now (y/n) : "); char choice = Console.ReadLine()[0]; if (choice == 'y' || choice == 'Y') { pin = this.getAtmPinFromUser(); userInteracting.AccountsData.AllAtmCards.Add(new Atm(accountNo, pin)); } else { Console.WriteLine("Bye! Come back when you want or have an atm card"); Environment.Exit(0); } } SavingAccount accountInfoOfTheUserWhoLoggedIn = userInteracting.AccountsData.AllSavingAccountsList[userInteracting.getCurrentAccountIndex(accountNo)]; do { Console.Clear(); Console.WriteLine("Press 0 to exit"); Console.WriteLine("Press 1 to get account details"); Console.WriteLine("Press 2 to deposit an amount"); Console.WriteLine("Press 3 to withdraw an amount"); char choice = Console.ReadLine()[0]; switch (choice) { case '0': userInteracting.writeBackAllFiles(); Environment.Exit(0); break; case '1': this.printOneSavingAccount(accountInfoOfTheUserWhoLoggedIn); break; case '2': pin = this.getAtmPinFromUser(); if (userInteracting.verifyCredentials(accountInfoOfTheUserWhoLoggedIn.AccountNo, pin)) { userInteracting.makeDepositToSavingAccount(accountNo); } else { Console.WriteLine("You entered incorrect pin"); } break; case '3': pin = this.getAtmPinFromUser(); if (userInteracting.verifyCredentials(accountInfoOfTheUserWhoLoggedIn.AccountNo, pin)) { userInteracting.makeTransactionFromSavingAccount(accountNo); } else { Console.WriteLine("You entered incorrect pin"); } break; default: break; } } while (askIfUserWantsToContinue()); } }
public void printOneSavingAccount(SavingAccount savingAccountToPrint) { Console.WriteLine(savingAccountToPrint.getAccountData() + "\n"); }