質問編集履歴
2
ソースコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
**わからない内容**
|
14
14
|
|
15
|
-
putCommand() の中にある return(inputCommand()); がどのような処理をしているのかがわかりません。
|
15
|
+
inputCommand() の中にある return(inputCommand()); がどのような処理をしているのかがわかりません。
|
16
|
+
|
16
|
-
|
17
|
+
putCommand() の中にある int c = inputCommand(); がどのような処理をしているのかがわかりません。
|
17
|
-
|
18
18
|
|
19
19
|
|
20
20
|
|
1
ソースコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,17 +6,65 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
---
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
**わからない内容**
|
14
|
+
|
15
|
+
putCommand() の中にある return(inputCommand()); がどのような処理をしているのかがわかりません。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
9
|
-
|
21
|
+
``` 言語:Java
|
22
|
+
|
10
|
-
|
23
|
+
public class part01
|
24
|
+
|
25
|
+
{
|
26
|
+
|
27
|
+
static String name = "すけさん";
|
28
|
+
|
29
|
+
static int lv = 30; //プレイヤーのレベル
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
public static void main(String[] args) throws java.io.IOException
|
34
|
+
|
35
|
+
{
|
36
|
+
|
37
|
+
putJyosyou(); //序章を表示
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
putCommand(); //コマンドを表示
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
if(lv<40){ //レベルが40未満の場合
|
46
|
+
|
47
|
+
putGameOver(); //ゲームオーバー画面を表示
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
}else{ //レベルが40以上の場合
|
52
|
+
|
53
|
+
putGameClear(); //ゲームクリアの画面を表示
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
11
|
-
public static void putCommand() throws java.io.IOException
|
61
|
+
public static void putCommand() throws java.io.IOException
|
12
62
|
|
13
63
|
{
|
14
64
|
|
15
65
|
System.out.println("1. 魔王を倒しに行く");
|
16
66
|
|
17
|
-
|
18
|
-
|
19
|
-
|
67
|
+
System.out.println("2. 修行する");
|
20
68
|
|
21
69
|
int c = inputCommand();
|
22
70
|
|
@@ -56,6 +104,104 @@
|
|
56
104
|
|
57
105
|
}
|
58
106
|
|
107
|
+
/**
|
108
|
+
|
109
|
+
* 序章を表示します
|
110
|
+
|
111
|
+
*/
|
112
|
+
|
113
|
+
public static void putJyosyou()
|
114
|
+
|
115
|
+
{
|
116
|
+
|
117
|
+
System.out.println("魔王が" + "世界を滅ぼそうとしています。");
|
118
|
+
|
119
|
+
System.out.println(name + "はレベル" + lv + "のツワモノです。");
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
|
125
|
+
* ゲームオーバー画面を表示します
|
126
|
+
|
127
|
+
*/
|
128
|
+
|
129
|
+
public static void putGameOver()
|
130
|
+
|
131
|
+
{
|
132
|
+
|
133
|
+
System.out.println(name + "は魔王に敗れましたorz");
|
134
|
+
|
135
|
+
System.out.println("GAME OVER");
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
/**
|
140
|
+
|
141
|
+
* ゲームクリア画面を表示します
|
142
|
+
|
143
|
+
*/
|
144
|
+
|
145
|
+
public static void putGameClear()
|
146
|
+
|
147
|
+
{
|
148
|
+
|
149
|
+
String s0 = name + "は魔王を倒しました!";
|
150
|
+
|
151
|
+
put(s0);
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
System.out.print("レベル" + lv);
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
if(lv>200){
|
160
|
+
|
161
|
+
put("なので魔王はゴミでした。www");
|
162
|
+
|
163
|
+
}else if(lv>120){
|
164
|
+
|
165
|
+
put("なので魔王は弱すぎでした。");
|
166
|
+
|
167
|
+
}else if(lv>80){
|
168
|
+
|
169
|
+
put("なので余裕でした。");
|
170
|
+
|
171
|
+
}else if(lv>50){
|
172
|
+
|
173
|
+
put("でしたが倒せました。");
|
174
|
+
|
175
|
+
}else{
|
176
|
+
|
177
|
+
put("でしたので苦戦しました。");
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
put("GAME CLEAR!");
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
/**
|
186
|
+
|
187
|
+
* 引数で指定された文字列を表示します
|
188
|
+
|
189
|
+
*
|
190
|
+
|
191
|
+
* @param str 表示対象の文字列
|
192
|
+
|
193
|
+
*/
|
194
|
+
|
195
|
+
public static void put(String str)
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
System.out.println(str);
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
}
|
204
|
+
|
59
205
|
```
|
60
206
|
|
61
207
|
**ソースコード元**
|