Advertisement
Guest User

lesson

a guest
Nov 15th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         Analyze analyze = new Analyze();
  7.         int scan = -1;
  8.         String s;
  9.         String[] commands = {"start", "add", "delete", "move", "print", "fire", "exit"};
  10.         while (1 == 1) {
  11.             scan = -1;
  12.             s = sc.nextLine();
  13.             for (int i = 0; i < 7; i++) {
  14.                 if (s.equalsIgnoreCase(commands[i])) {
  15.                     scan = i;
  16.                 } else if (i == 6 && scan == -1){
  17.                     System.out.println("Again");
  18.                 }
  19.             }
  20.             if (scan == 0) {
  21.                 analyze.start();
  22.             } else if (scan == 1) {
  23.                 analyze.add();
  24.             } else if (scan == 2) {
  25.                 analyze.delete();
  26.             } else if (scan == 3) {
  27.                 analyze.move();
  28.             } else if (scan == 4) {
  29.                 analyze.print();
  30.             } else if (scan == 5) {
  31.                 analyze.fire();
  32.             } else if (scan == 6) {
  33.                 analyze.exit();
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement