fork download
  1. import java.util.Hashtable;
  2. import java.util.Scanner;
  3.  
  4. public class Env {
  5. Scanner scanner = new Scanner(System.in);
  6. int x = -1;
  7. int num;
  8. boolean turn;
  9. Hashtable<String, String> msg = new Hashtable<String, String>();
  10. public Env(int num, boolean turn, Hashtable<String, String> msg) {
  11. this.num = num;
  12. this.turn = turn;
  13. this.msg = msg;
  14. }
  15. Env read(){
  16. if (this.turn) {
  17. while (true) {
  18. System.out.printf(this.msg.get("take"), this.num > 3 ? 3: this.num);
  19. this.x = scanner.nextInt();
  20. if (this.x > 0 && ((this.num > 3 && this.x < 4) || this.x < this.num + 1)) {
  21. break;
  22. }
  23. }
  24. }
  25. return this;
  26. }
  27. Env eval() {
  28. if (!this.turn) {
  29. switch (this.num % 4) {
  30. case 0:
  31. this.x = 3;
  32. break;
  33. case 1:
  34. if (this.num == 1) {
  35. this.x = 1;
  36. } else {
  37. switch (this.x) {
  38. case 1:
  39. this.x = 3;
  40. break;
  41. case 2:
  42. this.x = 2;
  43. break;
  44. case 3:
  45. this.x = 1;
  46. break;
  47. }
  48. }
  49. case 2:
  50. this.x = 1;
  51. break;
  52. case 3:
  53. this.x = 2;
  54. break;
  55. }
  56. }
  57. this.num -= this.x;
  58. this.turn = !this.turn;
  59. return this;
  60. }
  61. Env print() {
  62. if (this.turn) {
  63. System.out.printf(this.msg.get("took"), this.msg.get("comp"), this.x);
  64. }
  65. System.out.printf(this.msg.get("cond"), this.num);
  66. return this;
  67. }
  68. }
  69.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class Env is public, should be declared in a file named Env.java
public class Env {
       ^
1 error
stdout
Standard output is empty