fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Player4 p = new Player4();
  10. while(p.isAlive()){
  11. p.print();
  12. p.work();
  13. }
  14. p.print();
  15. }
  16. }
  17.  
  18. class Player4{
  19. private int hp;
  20. private int place;
  21.  
  22. public Player4(){
  23. hp=100;
  24. place=0;
  25. }
  26.  
  27. public void work(){
  28. if(1<=hp){
  29. hp--;
  30. place++;
  31. } else {
  32. System.out.println("dead...");
  33. }
  34. }
  35.  
  36. public boolean isAlive(){
  37. if(1<=hp){
  38. return true;
  39. } else {
  40. return false;
  41.  
  42. }
  43. }
  44.  
  45. public void print(){
  46. System.out.println(hp+", "+place);
  47. }
  48. }
Success #stdin #stdout 0.12s 55476KB
stdin
Standard input is empty
stdout
100, 0
99, 1
98, 2
97, 3
96, 4
95, 5
94, 6
93, 7
92, 8
91, 9
90, 10
89, 11
88, 12
87, 13
86, 14
85, 15
84, 16
83, 17
82, 18
81, 19
80, 20
79, 21
78, 22
77, 23
76, 24
75, 25
74, 26
73, 27
72, 28
71, 29
70, 30
69, 31
68, 32
67, 33
66, 34
65, 35
64, 36
63, 37
62, 38
61, 39
60, 40
59, 41
58, 42
57, 43
56, 44
55, 45
54, 46
53, 47
52, 48
51, 49
50, 50
49, 51
48, 52
47, 53
46, 54
45, 55
44, 56
43, 57
42, 58
41, 59
40, 60
39, 61
38, 62
37, 63
36, 64
35, 65
34, 66
33, 67
32, 68
31, 69
30, 70
29, 71
28, 72
27, 73
26, 74
25, 75
24, 76
23, 77
22, 78
21, 79
20, 80
19, 81
18, 82
17, 83
16, 84
15, 85
14, 86
13, 87
12, 88
11, 89
10, 90
9, 91
8, 92
7, 93
6, 94
5, 95
4, 96
3, 97
2, 98
1, 99
0, 100