質問編集履歴

1

書式の改善

2018/06/11 23:19

投稿

Nerd_run.
Nerd_run.

スコア60

test CHANGED
File without changes
test CHANGED
@@ -38,164 +38,164 @@
38
38
 
39
39
  command();
40
40
 
41
+ }
42
+
43
+ }
44
+
45
+
46
+
47
+ static void joshou(){ //序章を出力
48
+
49
+
50
+
51
+ System.out.println( "魔王が世界を滅ぼそうとしています。" );
52
+
53
+ }
54
+
55
+
56
+
57
+ static void status(){ //ステータスを出力
58
+
59
+
60
+
61
+ System.out.println("--------------------------------------");
62
+
63
+ System.out.println( name + " Lv :" + lv + " HP :" + hp + " Gold :" + gold + "G" );
64
+
65
+ System.out.println("--------------------------------------");
66
+
67
+ }
68
+
69
+
70
+
71
+ static void command() throws IOException { //コマンドを表示
72
+
73
+
74
+
75
+ status();
76
+
77
+
78
+
79
+ System.out.println( " 1, 魔王を倒しに行く。" );
80
+
81
+ System.out.println( " 2, 修行する。" );
82
+
83
+ System.out.println( " 3, 宿屋に泊まる" );
84
+
85
+ System.out.println("--------------------------------------");
86
+
87
+
88
+
89
+ cmd();
90
+
91
+ }
92
+
93
+
94
+
95
+ static void cmd() throws IOException { //コマンド処理設定
96
+
97
+
98
+
99
+ int c = System.in.read();
100
+
101
+
102
+
103
+ switch( c ) {
104
+
105
+
106
+
107
+ case ( '1' ) :
108
+
109
+
110
+
111
+ if( lv < 40 ){
112
+
113
+ System.out.println( "魔王に敗れた。" );
114
+
115
+ gameover();
116
+
117
+ }else{
118
+
119
+ gameclear();
120
+
121
+ }
122
+
123
+
124
+
125
+ break;
126
+
127
+
128
+
129
+ case ( '2' ) :
130
+
131
+
132
+
133
+ Random rnd = new Random();
134
+
135
+ int monster = rnd.nextInt( 5 )+ 1;
136
+
137
+ int damage = rnd.nextInt( 5 );
138
+
139
+ int ex = rnd.nextInt( 5 );
140
+
141
+
142
+
143
+ System.out.println( "敵が " + monster + "匹 現れた。" );
144
+
145
+
146
+
147
+ hp -= damage;
148
+
149
+
150
+
151
+ if( hp < 0 ){
152
+
153
+ hp = 0;
154
+
155
+ }
156
+
157
+
158
+
159
+ if( hp > 0 ){
160
+
161
+ System.out.println( name + "は " + damage + " のダメージを受けた。" );
162
+
163
+ System.out.println( "敵を倒した。" + name + "は経験値を " + ex + " 獲得した。" );
164
+
165
+ lv += ex;
166
+
167
+ }else{
168
+
169
+ System.out.println( name + "は" + damage + "のダメージを受けた。" );
170
+
171
+ System.out.println( "HPが0になった。" );
172
+
173
+ gameover();
174
+
175
+ }
176
+
177
+
178
+
179
+ System.out.println(); //改行
180
+
181
+ break;
182
+
183
+
184
+
185
+ case ( '3' ) :
186
+
187
+
188
+
189
+ System.out.println( "HPが回復した。" );
190
+
191
+ hp = hp;
192
+
193
+
194
+
195
+ break;
196
+
41
197
  }
42
198
 
43
-
44
-
45
- if( hp == 0 ){
46
-
47
- gameover();
48
-
49
- }
50
-
51
- }
52
-
53
-
54
-
55
- static void joshou(){ //序章を出力
56
-
57
-
58
-
59
- System.out.println( "魔王が世界を滅ぼそうとしています。" );
60
-
61
- }
62
-
63
-
64
-
65
- static void status(){ //ステータスを出力
66
-
67
-
68
-
69
- System.out.println("--------------------------------------");
70
-
71
- System.out.println( name + " Lv :" + lv + " HP :" + hp + " Gold :" + gold + "G" );
72
-
73
- System.out.println("--------------------------------------");
74
-
75
- }
76
-
77
-
78
-
79
- static void command() throws IOException { //コマンドを表示
80
-
81
-
82
-
83
- status();
84
-
85
-
86
-
87
- System.out.println( " 1, 魔王を倒しに行く。" );
88
-
89
- System.out.println( " 2, 修行する。" );
90
-
91
- System.out.println( " 3, 宿屋に泊まる" );
92
-
93
- System.out.println("--------------------------------------");
94
-
95
-
96
-
97
- if( hp < 0 ){
98
-
99
- hp = 0;
100
-
101
- System.out.println( "HPが0になった。" );
102
-
103
- gameover();
104
-
105
- }
106
-
107
-
108
-
109
- cmd();
110
-
111
- }
112
-
113
-
114
-
115
- static void cmd() throws IOException { //コマンド処理設定
116
-
117
-
118
-
119
- int c = System.in.read();
120
-
121
-
122
-
123
- switch( c ) {
124
-
125
-
126
-
127
- case ( '1' ) :
128
-
129
-
130
-
131
- if( lv < 40 ){
132
-
133
- System.out.println( "魔王に敗れた。" );
134
-
135
- gameover();
136
-
137
- }else{
138
-
139
- gameclear();
140
-
141
- }
142
-
143
-
144
-
145
- break;
146
-
147
-
148
-
149
- case ( '2' ) :
150
-
151
-
152
-
153
- Random rnd = new Random();
154
-
155
- int monster = rnd.nextInt( 5 )+ 1;
156
-
157
- int damage = rnd.nextInt( 5 );
158
-
159
- int ex = rnd.nextInt( 5 );
160
-
161
-
162
-
163
- System.out.println( "敵が " + monster + "匹現れた。" );
164
-
165
-
166
-
167
- System.out.println( name + "は" + damage + "のダメージを受けた。" );
168
-
169
- hp -= damage;
170
-
171
-
172
-
173
- System.out.println( "敵を倒した。" + name + "は、" + ex + "の経験値を手に入れた。" );
174
-
175
- lv += ex;
176
-
177
-
178
-
179
- System.out.println(); //改行
180
-
181
- break;
182
-
183
-
184
-
185
- case ( '3' ) :
186
-
187
-
188
-
189
- System.out.println( "HPが回復した。" );
190
-
191
- hp = hp;
192
-
193
-
194
-
195
- break;
196
-
197
- }
198
-
199
199
  }
200
200
 
201
201