Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.67 KB | None | 0 0
  1. public class AccountTUI
  2. {
  3.     private Scanner myScanner;
  4.     private ArrayList<Account> accounts;
  5.     private Account account;
  6.  
  7.     public AccountTUI()
  8.     {
  9.         myScanner = new Scanner(System.in);
  10.         AccountList account = new AccountList();
  11.         //account = new Account("first name", "last name", "account number", "address1", "address2", "address3");
  12.  
  13.     }
  14.  
  15.     public void menu()
  16.     {
  17.         int command = -1;
  18.         while ( command != 0 )
  19.         {
  20.             displayMenu();
  21.             command = getCommand();
  22.             execute( command );
  23.         }
  24.     }
  25.  
  26.     private void displayMenu()
  27.     {
  28.         System.out.println();
  29.         System.out.println("Options are" );
  30.         System.out.println("To add account enter 1");
  31.         System.out.println("To get number of accounts enter 2");
  32.         System.out.println("To show account enter 3");    
  33.         System.out.println("To show all accounts enter 4");
  34.         System.out.println("To remove account enter 5");
  35.         System.out.println("To exit enter 0");
  36.     }
  37.  
  38.     private void execute( int command)
  39.     {
  40.         if ( command == 1)
  41.             addAccount();
  42.         else if ( command == 2 )
  43.             getNumberOfAccounts();
  44.         else if ( command == 3)
  45.             showAccount();
  46.         else if ( command == 4 )
  47.             showAllAccounts();
  48.         else if ( command == 5)
  49.             removeAccount();
  50.         else if ( command == 0)
  51.             quitCommand();
  52.         else
  53.             unknownCommand(command);
  54.     }
  55.  
  56.     private int getCommand()
  57.     {
  58.         System.out.print ("Enter command: ");
  59.         int command = myScanner.nextInt();
  60.         return command;
  61.     }
  62.  
  63.     public void addAccount()
  64.     {
  65.         System.out.print("Enter first name: ");
  66.         String firstName = myScanner.nextLine();
  67.         System.out.print("Enter last name: ");
  68.         String lastName = myScanner.nextLine();
  69.         System.out.print("Enter account number: ");
  70.         String accountNumber = myScanner.nextLine();
  71.     }
  72.  
  73.     public void getNumberOfAccounts()
  74.     {
  75.         System.out.println("We have " + accounts.size() + " accounts.");
  76.     }
  77.  
  78.     public void quitCommand()
  79.     {
  80.         System.out.println("Program closing down");
  81.         System.exit(0);
  82.     }
  83.  
  84.     public void removeAccount()
  85.     {
  86.     }
  87.  
  88.     public void showAccount()
  89.     {
  90.  
  91.     }
  92.  
  93.     public void showAllAccounts()
  94.     {
  95.         for (Account account:accounts)
  96.         AccountList.getAllAccounts();
  97.        
  98.         //for (ArrayList Account: accounts)
  99.             //account.printAccountDetails();
  100.         //System.out.println();
  101.         //System.out.println(account);
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement