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