fork download
  1. import java.util.Hashtable;
  2. import java.util.Random;
  3.  
  4. public class Nim {
  5. public static void main(String[] args) {
  6. Hashtable<String, String> msg = new Hashtable<String, String>();
  7.  
  8. msg.put("you", "あなた");
  9. msg.put("comp", "コンピュータ");
  10. msg.put("took", "%sが%d個取った\n");
  11. msg.put("take", "石を取って!(1〜%d) > ");
  12. msg.put("cond", "現在の石の数: %d\n\n");
  13. msg.put("win", "%sの勝ち\n");
  14.  
  15. Random rnd = new Random();
  16. boolean bVal = rnd.nextBoolean();
  17. Env env = new Env(15, bVal, msg);
  18. System.out.printf("%sが先攻\n", bVal ? msg.get("you"): msg.get("comp"));
  19. while (env.num > 0) {
  20. env.read().eval().print();
  21. }
  22. System.out.printf(msg.get("win"), env.turn ? msg.get("you") : msg.get("comp"));
  23. }
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class Nim is public, should be declared in a file named Nim.java
public class Nim {
       ^
Main.java:17: error: cannot find symbol
        Env env = new Env(15, bVal, msg);
        ^
  symbol:   class Env
  location: class Nim
Main.java:17: error: cannot find symbol
        Env env = new Env(15, bVal, msg);
                      ^
  symbol:   class Env
  location: class Nim
3 errors
stdout
Standard output is empty