Advertisement
vesso8

BankAccount

May 13th, 2021
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Bank_Acount;
  2.  
  3. import java.util.Scanner;
  4. import java.util.Set;
  5.  
  6. public class BankClient {
  7.     private int current = -1;
  8.     private Scanner scanner = new Scanner(System.in);
  9.     private boolean done = false;
  10.     private Bank bank = new Bank();
  11.     public void run(){
  12.         scanner = new Scanner(System.in);
  13.         while(!done){
  14.             System.out.print("Enter command (0=quit, 1=new, 2=select, 3=deposit, 4=loan, 5=show, 6=interest)");
  15.             int cmd = scanner.nextInt();
  16.             proccessCommand(cmd);
  17.         }
  18.     }
  19.     private void proccessCommand(int cmd){
  20.         if(cmd == 0) quit();
  21.         else if (cmd == 1) newAccount();
  22.         else if (cmd == 2) select();
  23.         else if (cmd == 3) deposit();
  24.         else if (cmd == 4) authorizeLoan();
  25.         else if (cmd == 5) showAll();
  26.         else if (cmd == 6) addInterest();
  27.         else
  28.             System.out.println("Invalid command");
  29.  
  30.     }
  31.     private void newAccount(){
  32.         current = bank.newAccount();
  33.         System.out.println("Your new account is: " + current);
  34.     }
  35.     private void select(){
  36.         System.out.print("Enter Accounts: ");
  37.         current = scanner.nextInt();
  38.         int balance = bank.getBalance(current);
  39.         System.out.println("The balance of account "  + current + " is " + balance);
  40.  
  41.     }
  42.     private void deposit(){
  43.         System.out.print("Enter deposit amount: ");
  44.         int amount = scanner.nextInt();
  45.         bank.deposit(current, amount);
  46.     }
  47.     private void authorizeLoan(){
  48.         System.out.print("Enter loan amount: ");
  49.         int loanamount = scanner.nextInt();
  50.         if(bank.authorizeLoan(current, loanamount))
  51.             System.out.println("Your loan is confirmed");
  52.         else
  53.             System.out.println("Your loan is declined");
  54.     }
  55.     private void showAll(){
  56.         System.out.println(bank.toString());
  57.     }
  58.     private void quit() {
  59.         done = true;
  60.         System.out.println("Goodbye!");
  61.     }
  62.     private void addInterest(){
  63.         Set<Integer>accts = accounts.keySet();
  64.         for(int i : accts){
  65.             int balance = accounts.get(1);
  66.             int newbalance = (int) (balance * (1+rate));
  67.         }
  68.  
  69.     }
  70. }
  71.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement