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