質問編集履歴
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -70,6 +70,14 @@
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
```Java
|
78
|
+
|
79
|
+
|
80
|
+
|
73
81
|
class aoki extends Player{
|
74
82
|
|
75
83
|
public aoki(String name,int winCount){
|
@@ -92,6 +100,12 @@
|
|
92
100
|
|
93
101
|
|
94
102
|
|
103
|
+
```
|
104
|
+
|
105
|
+
```Java
|
106
|
+
|
107
|
+
|
108
|
+
|
95
109
|
class Inoue extends Player{
|
96
110
|
|
97
111
|
public Inoue(String name,int winCount){
|
@@ -114,6 +128,12 @@
|
|
114
128
|
|
115
129
|
|
116
130
|
|
131
|
+
```
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```Java
|
136
|
+
|
117
137
|
|
118
138
|
|
119
139
|
//じゃんけんの審判を表すクラス
|
@@ -206,7 +226,11 @@
|
|
206
226
|
|
207
227
|
|
208
228
|
|
209
|
-
|
229
|
+
```
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
```Java
|
210
234
|
|
211
235
|
public class Objectjanken{
|
212
236
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,226 +24,224 @@
|
|
24
24
|
|
25
25
|
### 該当のソースコード
|
26
26
|
|
27
|
-
```Java
|
27
|
+
```Java> 引用テキスト
|
28
|
+
|
28
|
-
|
29
|
+
class Player{
|
30
|
+
|
31
|
+
private String name; //名前
|
32
|
+
|
33
|
+
private int winCount = 0; //勝ち数(初期値:0)
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
public int getWinCount(){
|
40
|
+
|
41
|
+
//プレイヤーの勝ち数
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
winCount = winCount+1;
|
46
|
+
|
47
|
+
return winCount;
|
48
|
+
|
49
|
+
|
50
|
+
|
29
|
-
|
51
|
+
}
|
52
|
+
|
53
|
+
public String getName(){
|
54
|
+
|
55
|
+
return name;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
public Player (String name,int winCount){
|
62
|
+
|
63
|
+
this.name = name;
|
64
|
+
|
65
|
+
this.winCount = winCount;
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
class aoki extends Player{
|
74
|
+
|
75
|
+
public aoki(String name,int winCount){
|
76
|
+
|
77
|
+
super(name,winCount);
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
public int showHand(){
|
84
|
+
|
85
|
+
int playerhand =0; //相手の出す手をグーで決定
|
86
|
+
|
87
|
+
return playerhand;
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
class Inoue extends Player{
|
96
|
+
|
97
|
+
public Inoue(String name,int winCount){
|
98
|
+
|
99
|
+
super(name,winCount);
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
public int showHand(){
|
106
|
+
|
107
|
+
int playerhand =0; //相手の出す手をパーで決定
|
108
|
+
|
109
|
+
return playerhand;
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
//じゃんけんの審判を表すクラス
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
class judge{
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
//じゃんけんを開始する
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
public void startJanken(aoki Aoki,Inoue inoue){
|
132
|
+
|
133
|
+
System.out.println("【じゃんけん開始を開始します】");
|
134
|
+
|
135
|
+
int a = Aoki.showHand();
|
136
|
+
|
137
|
+
int b = inoue.showHand();
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
String[] str = {"グー","チョキ","パ-"}; //表示列配列
|
142
|
+
|
143
|
+
System.out.println(Aoki.getName()+"は"+str[a]+"、"+inoue.getName()+"は"+str[b]+"です。");
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
//じゃんけんの判定
|
152
|
+
|
153
|
+
if((a==2 &&b==0)||(a==1 && b==2)||(a==0 && b==1)){
|
154
|
+
|
155
|
+
System.out.println(Aoki.getName()+"の勝利");
|
156
|
+
|
157
|
+
Aoki.getWinCount();
|
158
|
+
|
159
|
+
//player2win
|
160
|
+
|
161
|
+
}else if((a==0 && b==2)||(a==1 && b==0)||(a==2 && b==1)){
|
162
|
+
|
163
|
+
System.out.println(inoue.getName()+"の勝利");
|
164
|
+
|
165
|
+
inoue.getWinCount();
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
//引き分けの場合
|
172
|
+
|
173
|
+
}else if((a==0 && b==0)||(a==1&& b==1)||(a==2&& b==2)){
|
174
|
+
|
175
|
+
System.out.println("引き分けの場合やり直し");
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
//勝者を決める
|
188
|
+
|
189
|
+
public void judgeFinalWinner(aoki Aoki,Inoue inoue){
|
190
|
+
|
191
|
+
if(Aoki.getWinCount()>inoue.getWinCount()){
|
192
|
+
|
193
|
+
System.out.println((Aoki.getWinCount()-2)+"対"+(inoue.getWinCount()-2)+"で"+Aoki.getName()+"の勝利");
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
}else if(Aoki.getWinCount()<inoue.getWinCount()){
|
198
|
+
|
199
|
+
System.out.println((Aoki.getWinCount()-3)+"対"+(inoue.getWinCount()-3)+"で"+inoue.getName()+"の勝利");
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
public class Objectjanken{
|
212
|
+
|
213
|
+
public static void main(String[]args){
|
214
|
+
|
215
|
+
//審判(上田さん)のインスタンス
|
216
|
+
|
217
|
+
judge ueda = new judge();
|
218
|
+
|
219
|
+
//プレイヤー1とプレイヤー2の作成
|
220
|
+
|
221
|
+
Player Aoki = new aoki("青木",0);
|
222
|
+
|
223
|
+
Player inoue = new Inoue("井上",0);
|
224
|
+
|
225
|
+
//2人のじゃんけんを開始する
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
ueda.startJanken(Aoki,inoue);
|
230
|
+
|
231
|
+
ueda.judgeFinalWinner(Aoki,inoue);
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
30
242
|
|
31
243
|
```
|
32
244
|
|
33
|
-
class Player{
|
34
|
-
|
35
|
-
private String name; //名前
|
36
|
-
|
37
|
-
private int winCount = 0; //勝ち数(初期値:0)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
public int getWinCount(){
|
44
|
-
|
45
|
-
//プレイヤーの勝ち数
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
winCount = winCount+1;
|
50
|
-
|
51
|
-
return winCount;
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
public String getName(){
|
58
|
-
|
59
|
-
return name;
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
public Player (String name,int winCount){
|
66
|
-
|
67
|
-
this.name = name;
|
68
|
-
|
69
|
-
this.winCount = winCount;
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
class aoki extends Player{
|
78
|
-
|
79
|
-
public aoki(String name,int winCount){
|
80
|
-
|
81
|
-
super(name,winCount);
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
public int showHand(){
|
88
|
-
|
89
|
-
int playerhand =0; //相手の出す手をグーで決定
|
90
|
-
|
91
|
-
return playerhand;
|
92
|
-
|
93
|
-
}
|
94
|
-
|
95
|
-
}
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
class Inoue extends Player{
|
100
|
-
|
101
|
-
public Inoue(String name,int winCount){
|
102
|
-
|
103
|
-
super(name,winCount);
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
public int showHand(){
|
110
|
-
|
111
|
-
int playerhand =0; //相手の出す手をパーで決定
|
112
|
-
|
113
|
-
return playerhand;
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
//じゃんけんの審判を表すクラス
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
class judge{
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
//じゃんけんを開始する
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
public void startJanken(aoki Aoki,Inoue inoue){
|
136
|
-
|
137
|
-
System.out.println("【じゃんけん開始を開始します】");
|
138
|
-
|
139
|
-
int a = Aoki.showHand();
|
140
|
-
|
141
|
-
int b = inoue.showHand();
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
String[] str = {"グー","チョキ","パ-"}; //表示列配列
|
146
|
-
|
147
|
-
System.out.println(Aoki.getName()+"は"+str[a]+"、"+inoue.getName()+"は"+str[b]+"です。");
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
//じゃんけんの判定
|
156
|
-
|
157
|
-
if((a==2 &&b==0)||(a==1 && b==2)||(a==0 && b==1)){
|
158
|
-
|
159
|
-
System.out.println(Aoki.getName()+"の勝利");
|
160
|
-
|
161
|
-
Aoki.getWinCount();
|
162
|
-
|
163
|
-
//player2win
|
164
|
-
|
165
|
-
}else if((a==0 && b==2)||(a==1 && b==0)||(a==2 && b==1)){
|
166
|
-
|
167
|
-
System.out.println(inoue.getName()+"の勝利");
|
168
|
-
|
169
|
-
inoue.getWinCount();
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
//引き分けの場合
|
176
|
-
|
177
|
-
}else if((a==0 && b==0)||(a==1&& b==1)||(a==2&& b==2)){
|
178
|
-
|
179
|
-
System.out.println("引き分けの場合やり直し");
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
//勝者を決める
|
192
|
-
|
193
|
-
public void judgeFinalWinner(aoki Aoki,Inoue inoue){
|
194
|
-
|
195
|
-
if(Aoki.getWinCount()>inoue.getWinCount()){
|
196
|
-
|
197
|
-
System.out.println((Aoki.getWinCount()-2)+"対"+(inoue.getWinCount()-2)+"で"+Aoki.getName()+"の勝利");
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
}else if(Aoki.getWinCount()<inoue.getWinCount()){
|
202
|
-
|
203
|
-
System.out.println((Aoki.getWinCount()-3)+"対"+(inoue.getWinCount()-3)+"で"+inoue.getName()+"の勝利");
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
public class Objectjanken{
|
216
|
-
|
217
|
-
public static void main(String[]args){
|
218
|
-
|
219
|
-
//審判(上田さん)のインスタンス
|
220
|
-
|
221
|
-
judge ueda = new judge();
|
222
|
-
|
223
|
-
//プレイヤー1とプレイヤー2の作成
|
224
|
-
|
225
|
-
Player Aoki = new aoki("青木",0);
|
226
|
-
|
227
|
-
Player inoue = new Inoue("井上",0);
|
228
|
-
|
229
|
-
//2人のじゃんけんを開始する
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
ueda.startJanken(Aoki,inoue);
|
234
|
-
|
235
|
-
ueda.judgeFinalWinner(Aoki,inoue);
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
245
|
|
248
246
|
|
249
247
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,11 @@
|
|
24
24
|
|
25
25
|
### 該当のソースコード
|
26
26
|
|
27
|
-
|
27
|
+
```Java
|
28
|
+
|
29
|
+
コード
|
30
|
+
|
31
|
+
```
|
28
32
|
|
29
33
|
class Player{
|
30
34
|
|
@@ -92,6 +96,30 @@
|
|
92
96
|
|
93
97
|
|
94
98
|
|
99
|
+
class Inoue extends Player{
|
100
|
+
|
101
|
+
public Inoue(String name,int winCount){
|
102
|
+
|
103
|
+
super(name,winCount);
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
public int showHand(){
|
110
|
+
|
111
|
+
int playerhand =0; //相手の出す手をパーで決定
|
112
|
+
|
113
|
+
return playerhand;
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
95
123
|
//じゃんけんの審判を表すクラス
|
96
124
|
|
97
125
|
|
@@ -222,9 +250,7 @@
|
|
222
250
|
|
223
251
|
### 補足
|
224
252
|
|
225
|
-
|
253
|
+
|
226
|
-
|
227
|
-
|
228
254
|
|
229
255
|
【じゃんけんを開始します】
|
230
256
|
|
@@ -241,3 +267,9 @@
|
|
241
267
|
|
242
268
|
|
243
269
|
と表示したら成功です
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
情報追記しました
|
274
|
+
|
275
|
+
初心者すぎてまともに質問もできず申し訳ないです…
|