質問編集履歴
3
追記を削除
title
CHANGED
File without changes
|
body
CHANGED
@@ -208,76 +208,4 @@
|
|
208
208
|
|
209
209
|
}
|
210
210
|
|
211
|
-
}
|
211
|
+
}
|
212
|
-
|
213
|
-
|
214
|
-
ー追記ー
|
215
|
-
Board classに追加
|
216
|
-
|
217
|
-
public void actButton(){
|
218
|
-
|
219
|
-
for(int i=0; i<64; i++)
|
220
|
-
{
|
221
|
-
int x = i/8;
|
222
|
-
int y = i%8;
|
223
|
-
|
224
|
-
if(Piece.checkRev(x+1,y+1))
|
225
|
-
{
|
226
|
-
pButton[x][y].addActionListener(this);
|
227
|
-
}
|
228
|
-
else
|
229
|
-
{
|
230
|
-
pButton[x][y].addActionListener(null);
|
231
|
-
}
|
232
|
-
}
|
233
|
-
}
|
234
|
-
|
235
|
-
Piece classに追加
|
236
|
-
|
237
|
-
public static boolean checkRev(int sx, int sy){
|
238
|
-
|
239
|
-
int saveX = sx;
|
240
|
-
int saveY = sy;
|
241
|
-
|
242
|
-
int mx = -1;
|
243
|
-
int my = -2; // for文で+1スタートするので-2から始める
|
244
|
-
|
245
|
-
boolean result = true;
|
246
|
-
|
247
|
-
|
248
|
-
for(int i=0; i<8; i++)
|
249
|
-
{
|
250
|
-
sx = saveX;
|
251
|
-
sy = saveY;
|
252
|
-
|
253
|
-
if(mx == 0 && my == -1)
|
254
|
-
{
|
255
|
-
my = my + 2;
|
256
|
-
}
|
257
|
-
else if(my != 1)
|
258
|
-
{
|
259
|
-
my++;
|
260
|
-
}
|
261
|
-
else
|
262
|
-
{
|
263
|
-
mx++;
|
264
|
-
my = -1;
|
265
|
-
}
|
266
|
-
|
267
|
-
while(p[sx+mx][sy+my] != turn && p[sx+mx][sy+my] > 0)
|
268
|
-
{
|
269
|
-
sx = sx+mx;
|
270
|
-
sy = sy+my;
|
271
|
-
}
|
272
|
-
|
273
|
-
if(p[sx+mx][sy+my] == turn){
|
274
|
-
result = true;
|
275
|
-
}else{
|
276
|
-
result = false;
|
277
|
-
}
|
278
|
-
}
|
279
|
-
|
280
|
-
return result;
|
281
|
-
}
|
282
|
-
|
283
|
-
エラーはactButtonメソッドでnullPointerExceptionです。
|
2
新たに追加したメソッドでエラーが出る
title
CHANGED
File without changes
|
body
CHANGED
@@ -278,4 +278,6 @@
|
|
278
278
|
}
|
279
279
|
|
280
280
|
return result;
|
281
|
-
}
|
281
|
+
}
|
282
|
+
|
283
|
+
エラーはactButtonメソッドでnullPointerExceptionです。
|
1
「置けない」マスをクリックしてもボタンが作動しないように新たに2つメソッドを作りましたがうまく動作しません。 追記より下に新たに追加したメソッドを記述します。
title
CHANGED
File without changes
|
body
CHANGED
@@ -156,7 +156,7 @@
|
|
156
156
|
|
157
157
|
}
|
158
158
|
|
159
|
-
public static void
|
159
|
+
public static void doRev(int sx, int sy){
|
160
160
|
|
161
161
|
int saveX = sx;
|
162
162
|
int saveY = sy;
|
@@ -208,4 +208,74 @@
|
|
208
208
|
|
209
209
|
}
|
210
210
|
|
211
|
-
}
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
ー追記ー
|
215
|
+
Board classに追加
|
216
|
+
|
217
|
+
public void actButton(){
|
218
|
+
|
219
|
+
for(int i=0; i<64; i++)
|
220
|
+
{
|
221
|
+
int x = i/8;
|
222
|
+
int y = i%8;
|
223
|
+
|
224
|
+
if(Piece.checkRev(x+1,y+1))
|
225
|
+
{
|
226
|
+
pButton[x][y].addActionListener(this);
|
227
|
+
}
|
228
|
+
else
|
229
|
+
{
|
230
|
+
pButton[x][y].addActionListener(null);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
Piece classに追加
|
236
|
+
|
237
|
+
public static boolean checkRev(int sx, int sy){
|
238
|
+
|
239
|
+
int saveX = sx;
|
240
|
+
int saveY = sy;
|
241
|
+
|
242
|
+
int mx = -1;
|
243
|
+
int my = -2; // for文で+1スタートするので-2から始める
|
244
|
+
|
245
|
+
boolean result = true;
|
246
|
+
|
247
|
+
|
248
|
+
for(int i=0; i<8; i++)
|
249
|
+
{
|
250
|
+
sx = saveX;
|
251
|
+
sy = saveY;
|
252
|
+
|
253
|
+
if(mx == 0 && my == -1)
|
254
|
+
{
|
255
|
+
my = my + 2;
|
256
|
+
}
|
257
|
+
else if(my != 1)
|
258
|
+
{
|
259
|
+
my++;
|
260
|
+
}
|
261
|
+
else
|
262
|
+
{
|
263
|
+
mx++;
|
264
|
+
my = -1;
|
265
|
+
}
|
266
|
+
|
267
|
+
while(p[sx+mx][sy+my] != turn && p[sx+mx][sy+my] > 0)
|
268
|
+
{
|
269
|
+
sx = sx+mx;
|
270
|
+
sy = sy+my;
|
271
|
+
}
|
272
|
+
|
273
|
+
if(p[sx+mx][sy+my] == turn){
|
274
|
+
result = true;
|
275
|
+
}else{
|
276
|
+
result = false;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
return result;
|
281
|
+
}
|