fork download
  1. public class Cleric {
  2.  
  3. String name;
  4. int hp = 50;
  5. static final int MAXHP = 50;
  6. int mp = 10;
  7. static final int MAXMP = 10;
  8.  
  9. void selfAid() {
  10. this.mp -= 5;
  11. this.hp = MAXHP;
  12. System.out.println(this.name + "はセルフエイドを唱えた!HPが完全回復した!");
  13. }
  14.  
  15. int pray(int sec) {
  16. int recoverMp = sec + new java.util.Random().nextInt(3);
  17. int recoverMpActual = Math.min(this.MAXMP - this.mp, recoverMp);
  18. System.out.println(this.name + "は" + sec + "秒、天に祈った!MPが" + recoverMpActual + "ポイント回復した!");
  19. return recoverMpActual;
  20. }
  21.  
  22. Cleric(String name, int hp, int mp) {
  23. this.name = name;
  24. this.hp = hp;
  25. this.mp = mp;
  26. }
  27.  
  28. Cleric(String name, int hp) {
  29. this.name = name;
  30. this.hp = hp;
  31. this.mp = Cleric.MAXMP;
  32. }
  33.  
  34. Cleric(String name) {
  35. this.name = name;
  36. this.hp = Cleric.MAXHP;
  37. this.mp = Cleric.MAXMP;
  38. }
  39.  
  40. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class Cleric is public, should be declared in a file named Cleric.java
public class Cleric {
       ^
1 error
stdout
Standard output is empty