Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AccountTUI
- {
- private Scanner myScanner;
- private ArrayList<Account> accounts;
- private Account account;
- public AccountTUI()
- {
- myScanner = new Scanner(System.in);
- AccountList account = new AccountList();
- //account = new Account("first name", "last name", "account number", "address1", "address2", "address3");
- }
- public void menu()
- {
- int command = -1;
- while ( command != 0 )
- {
- displayMenu();
- command = getCommand();
- execute( command );
- }
- }
- private void displayMenu()
- {
- System.out.println();
- System.out.println("Options are" );
- System.out.println("To add account enter 1");
- System.out.println("To get number of accounts enter 2");
- System.out.println("To show account enter 3");
- System.out.println("To show all accounts enter 4");
- System.out.println("To remove account enter 5");
- System.out.println("To exit enter 0");
- }
- private void execute( int command)
- {
- if ( command == 1)
- addAccount();
- else if ( command == 2 )
- getNumberOfAccounts();
- else if ( command == 3)
- showAccount();
- else if ( command == 4 )
- showAllAccounts();
- else if ( command == 5)
- removeAccount();
- else if ( command == 0)
- quitCommand();
- else
- unknownCommand(command);
- }
- private int getCommand()
- {
- System.out.print ("Enter command: ");
- int command = myScanner.nextInt();
- return command;
- }
- public void addAccount()
- {
- System.out.print("Enter first name: ");
- String firstName = myScanner.nextLine();
- System.out.print("Enter last name: ");
- String lastName = myScanner.nextLine();
- System.out.print("Enter account number: ");
- String accountNumber = myScanner.nextLine();
- }
- public void getNumberOfAccounts()
- {
- System.out.println("We have " + accounts.size() + " accounts.");
- }
- public void quitCommand()
- {
- System.out.println("Program closing down");
- System.exit(0);
- }
- public void removeAccount()
- {
- }
- public void showAccount()
- {
- }
- public void showAllAccounts()
- {
- for (Account account:accounts)
- AccountList.getAllAccounts();
- //for (ArrayList Account: accounts)
- //account.printAccountDetails();
- //System.out.println();
- //System.out.println(account);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement