fork download
  1. class Player1 {
  2.  
  3. public int hp;
  4. public int place;
  5.  
  6. public Player1() {
  7. hp = 100;
  8. place = 0;
  9. }
  10. public void work() {
  11. hp--;
  12. place++;
  13. }
  14.  
  15. public void print() {
  16. System.out.println("HP: " + hp + ", Place: " + place); // hp と place を表示
  17. }
  18. }
  19.  
  20. class Game1 {
  21. public static void main(String[] args) {
  22.  
  23. Player1 p = new Player1();
  24.  
  25. p.print();
  26.  
  27. p.work();
  28.  
  29. p.print();
  30. }
  31. }
  32.  
Success #stdin #stdout 0.11s 57528KB
stdin
Standard input is empty
stdout
HP: 100, Place: 0
HP: 99, Place: 1