fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Player5 p = new Player5();
  13. while( p.isAlive() ){
  14. p.print();
  15. p.heal();
  16. p.work();
  17. }
  18. p.print();
  19. }
  20. }
  21.  
  22. class Player4b{
  23. protected int hp;
  24.  
  25. private int place;
  26. public Player4b(){
  27. hp = 100;
  28. place = 0;
  29. }
  30. public void work(){
  31. if( 3 <= hp ){
  32. hp -= 3;
  33. place ++;
  34. } else {
  35. System.out.println("dead...");
  36. }
  37. }
  38. public boolean isAlive(){
  39. if( 1 <= hp ){
  40. return true;
  41. } else {
  42. return false;
  43. }
  44. }
  45. public void print(){
  46. System.out.println(hp+", "+place);
  47. }
  48. }
  49.  
  50. class Player5 extends Player4b{
  51. public void heal(){
  52. hp += 1;
  53. }
  54. }
Success #stdin #stdout 0.11s 57624KB
stdin
Standard input is empty
stdout
100, 0
98, 1
96, 2
94, 3
92, 4
90, 5
88, 6
86, 7
84, 8
82, 9
80, 10
78, 11
76, 12
74, 13
72, 14
70, 15
68, 16
66, 17
64, 18
62, 19
60, 20
58, 21
56, 22
54, 23
52, 24
50, 25
48, 26
46, 27
44, 28
42, 29
40, 30
38, 31
36, 32
34, 33
32, 34
30, 35
28, 36
26, 37
24, 38
22, 39
20, 40
18, 41
16, 42
14, 43
12, 44
10, 45
8, 46
6, 47
4, 48
2, 49
0, 50