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 Player4
  9. {
  10. private int hp;
  11. private int place;
  12. public Player4(){
  13. hp=100;
  14. place=0;
  15. }
  16. public void work(){
  17. if(hp>=1){
  18. hp=hp-1;
  19. place=place+1;
  20. }
  21. else if(hp<=0){
  22. System.out.println("dead...");
  23. }
  24. }
  25. public boolean isAlive(){
  26. return hp>=1;
  27. }
  28. public void print(){
  29. System.out.println(hp);
  30. System.out.println(place);
  31. }
  32. }
  33. class Game4{
  34. public static void main (String[] args) throws java.lang.Exception{
  35. Player4 p=new Player4();
  36. while(p.isAlive()){
  37. p.print();
  38. p.work();
  39. }
  40. p.print();
  41. }
  42. }
Success #stdin #stdout 0.09s 17016KB
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