stoyanoff

Menu

Jul 4th, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.io.IOException;
  4. import java.util.Scanner;
  5.  
  6. public class Menu extends Account {
  7.  
  8.     Scanner myScan = new Scanner(System.in);
  9.  
  10.  
  11.  
  12.     public void menuGreeting() {
  13.         System.out.println("ATM Welcome Message");
  14.     }
  15.  
  16.     public void menuPrint() throws IOException {
  17.         menuGreeting();
  18.         System.out.println("Please enter one of the following choices");
  19.         System.out.println("1 - Display Balance");
  20.         System.out.println("2 - Deposit Money");
  21.         System.out.println("3 - Withdraw Money");
  22.         System.out.println("4 - Exit");
  23.         System.out.print("Enter Your Choice: ");
  24.  
  25.         int choice = myScan.nextInt();
  26.  
  27.         while (choice > 4) {
  28.             System.out.println("Wrong choice, please select 1-4 ");
  29.             System.out.print("Choice:");
  30.             choice = myScan.nextInt();
  31.  
  32.         } switch (choice) {
  33.             case 1:
  34.                 System.out.println("Display Balance Menu");
  35.                 menuBalance();
  36.                 returnMenu();
  37.                 break;
  38.             case 2:
  39.                 System.out.println("Deposit Money Menu");
  40.                 menuBalance();
  41.                 setBalance();
  42.                 returnMenu();
  43.                 break;
  44.             case 3:
  45.                 System.out.println("Withdraw Money Menu");
  46.                 returnMenu();
  47.                 break;
  48.             case 4:
  49.                 exitProgram();
  50.         }
  51.  
  52.  
  53.     }
  54.  
  55.     public void menuBalance() {
  56.         System.out.print("Your Current Balance is: $");
  57.         System.out.println(getBalance());
  58.     }
  59.  
  60.     public void menuDeposit() {
  61.  
  62.  
  63.     }
  64.  
  65.     public void menuWithdraw() {
  66.  
  67.     }
  68.  
  69.     public void exitProgram() {
  70.         System.out.println("Goodbye - Have a nice day");
  71.         System.exit(0);
  72.     }
  73.  
  74.     private void returnMenu() throws IOException {
  75.         System.out.println("To return in the main menu press 0");
  76.         System.out.println("To exit press 1");
  77.         System.out.print("Choice:");
  78.         int menuChoice = myScan.nextInt();
  79.         if (menuChoice == 0) {
  80.             menuPrint();
  81.         } else {
  82.             exitProgram();
  83.  
  84.         }
  85.     }
  86. }
Add Comment
Please, Sign In to add comment