質問編集履歴
1
皆様から頂いたアドバイスをもとに、引数numを利用せずに書き直しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,19 +36,17 @@
|
|
36
36
|
|
37
37
|
System.out.println("1.グー, 2.チョキ, 3.パー");
|
38
38
|
|
39
|
-
int i = new java.util.Scanner(System.in).nextInt();
|
39
|
+
int i = new java.util.Scanner(System.in).nextInt();
|
40
40
|
|
41
41
|
int Y = i - 1;
|
42
42
|
|
43
43
|
System.out.println("あなたは" + a[Y]);
|
44
44
|
|
45
|
-
int P = new java.util.Random().nextInt(3);
|
45
|
+
int P = new java.util.Random().nextInt(3);
|
46
46
|
|
47
47
|
System.out.println("PCは" + a[P]);
|
48
48
|
|
49
|
-
int num = 0;
|
50
|
-
|
51
|
-
int m
|
49
|
+
int num += janken(Y,P);
|
52
50
|
|
53
51
|
count++;
|
54
52
|
|
@@ -76,33 +74,31 @@
|
|
76
74
|
|
77
75
|
}
|
78
76
|
|
79
|
-
public static int janken(int Y,int P
|
77
|
+
public static int janken(int Y,int P){
|
80
78
|
|
81
79
|
if(Y == P){
|
82
80
|
|
83
81
|
System.out.println("あいこ");
|
84
82
|
|
85
|
-
return num;
|
86
|
-
|
87
83
|
}else if((Y == 0 && P == 1)||(Y == 1 && P == 2)||(Y == 2 && P == 0)){
|
88
84
|
|
89
85
|
System.out.println("あなたの勝ち");
|
90
86
|
|
91
|
-
return
|
87
|
+
return 1;
|
92
88
|
|
93
89
|
}else if((P == 0 && Y == 1)||(P == 1 && Y == 2)||(P == 2 && Y == 0)){
|
94
90
|
|
95
91
|
System.out.println("PCの勝ち");
|
96
92
|
|
97
|
-
return
|
93
|
+
return -1;
|
98
94
|
|
99
95
|
}
|
100
|
-
|
101
|
-
return num;//return文が指定されていません とのエラーが出たので便宜上指定
|
102
96
|
|
103
97
|
}
|
104
98
|
|
105
99
|
}
|
100
|
+
|
101
|
+
|
106
102
|
|
107
103
|
|
108
104
|
|
@@ -112,11 +108,19 @@
|
|
112
108
|
|
113
109
|
### 試したこと
|
114
110
|
|
111
|
+
java:13: エラー: ';'がありません
|
112
|
+
|
113
|
+
int num += janken(Y,P);
|
114
|
+
|
115
|
+
^
|
116
|
+
|
117
|
+
エラー1個
|
115
118
|
|
116
119
|
|
117
|
-
int num = 0
|
118
120
|
|
119
|
-
と
|
121
|
+
と出てしまいます。
|
122
|
+
|
123
|
+
|
120
124
|
|
121
125
|
### 補足情報(FW/ツールのバージョンなど)
|
122
126
|
|