DanikYakush

Task48

Jul 13th, 2022
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Task48 {
  4.     @SuppressWarnings("resource")
  5.  
  6.     static Scanner scanner = new Scanner(System.in);
  7.     static Customers customers = new Customers();
  8.  
  9.     public static void main(String[] args) {
  10.  
  11.         menuPrint();
  12.         menuChoise(menuValidation());
  13.  
  14.     }
  15.  
  16.     public static void menuPrint() {
  17.         System.out.println("menu is working");
  18.         System.out.println("1 for creating new customer");
  19.         System.out.println("2 for showing all customers in array");
  20.         System.out.println("3 for showing of sorted customers");
  21.         System.out.println("4 for search customers between card numbers");
  22.  
  23.     }
  24.  
  25.     public static void menuChoise(int menuchoise) {
  26.  
  27.         switch (menuchoise) {
  28.         case 1:
  29.             customers.pushCustomer(Customer.getNewCustomer());
  30.             menuPrint();
  31.             menuChoise(menuValidation());
  32.             break;
  33.  
  34.         case 2:
  35.             customers.showCustomer();
  36.             menuPrint();
  37.             menuChoise(menuValidation());
  38.             break;
  39.  
  40.         case 3:
  41.             customers.sortByName();
  42.             customers.showCustomer();
  43.             menuPrint();
  44.             menuChoise(menuValidation());
  45.             break;
  46.  
  47.         case 4:
  48.             System.out.println("give please start of interval");
  49.             String start = scanner.next();
  50.             System.out.println("give please end of interval");
  51.             String finish = scanner.next();
  52.             customers.print_if_card_in(start, finish);
  53.             menuPrint();
  54.             menuChoise(menuValidation());
  55.             break;
  56.  
  57.         default:
  58.             System.out.println("Something is going wrong");
  59.             menuPrint();
  60.             menuChoise(menuValidation());
  61.         }
  62.  
  63.     }
  64.  
  65.     public static int menuValidation() {
  66.        
  67.         if(scanner.hasNextInt()==true){
  68.             int value = scanner.nextInt();
  69.             return value;
  70.         } else {
  71.             System.out.println(scanner.next() +" is not a value as we need");
  72.             return 0;
  73.         }
  74.        
  75.  
  76.        
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment