예제 #1
0
  public static void main(String[] argv) {
    // Parse command-line args
    if (argv.length != 0) {
      usage();
      // System.exit(-1);
    }

    Thread visThread = new Thread(new Visualizer());
    visThread.start();

    // Poll for the user to end the simulation
    Scanner in = new Scanner(System.in);
    while (visThread.isAlive()) {
      String input = in.nextLine();
      if (input.equals("exit")) {
        finishUp();
        System.exit(0);
      } else if (input.equals("spawn")) {
        input = in.nextLine();
        for (int i = 0; i < Integer.parseInt(input); i++) fishtank.add();
      } else if (input.equals("print")) {
        fishtank.printState();
      } else if (input.equals("hyperspeed")) {
        fishtank.toggleHyperspeed();
      }
    }
  }