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