質問編集履歴
3
追記を削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -419,147 +419,3 @@
|
|
419
419
|
|
420
420
|
|
421
421
|
}
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
ー追記ー
|
428
|
-
|
429
|
-
Board classに追加
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
public void actButton(){
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
for(int i=0; i<64; i++)
|
438
|
-
|
439
|
-
{
|
440
|
-
|
441
|
-
int x = i/8;
|
442
|
-
|
443
|
-
int y = i%8;
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
if(Piece.checkRev(x+1,y+1))
|
448
|
-
|
449
|
-
{
|
450
|
-
|
451
|
-
pButton[x][y].addActionListener(this);
|
452
|
-
|
453
|
-
}
|
454
|
-
|
455
|
-
else
|
456
|
-
|
457
|
-
{
|
458
|
-
|
459
|
-
pButton[x][y].addActionListener(null);
|
460
|
-
|
461
|
-
}
|
462
|
-
|
463
|
-
}
|
464
|
-
|
465
|
-
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
Piece classに追加
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
public static boolean checkRev(int sx, int sy){
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
int saveX = sx;
|
478
|
-
|
479
|
-
int saveY = sy;
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
int mx = -1;
|
484
|
-
|
485
|
-
int my = -2; // for文で+1スタートするので-2から始める
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
boolean result = true;
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
for(int i=0; i<8; i++)
|
496
|
-
|
497
|
-
{
|
498
|
-
|
499
|
-
sx = saveX;
|
500
|
-
|
501
|
-
sy = saveY;
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
if(mx == 0 && my == -1)
|
506
|
-
|
507
|
-
{
|
508
|
-
|
509
|
-
my = my + 2;
|
510
|
-
|
511
|
-
}
|
512
|
-
|
513
|
-
else if(my != 1)
|
514
|
-
|
515
|
-
{
|
516
|
-
|
517
|
-
my++;
|
518
|
-
|
519
|
-
}
|
520
|
-
|
521
|
-
else
|
522
|
-
|
523
|
-
{
|
524
|
-
|
525
|
-
mx++;
|
526
|
-
|
527
|
-
my = -1;
|
528
|
-
|
529
|
-
}
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
while(p[sx+mx][sy+my] != turn && p[sx+mx][sy+my] > 0)
|
534
|
-
|
535
|
-
{
|
536
|
-
|
537
|
-
sx = sx+mx;
|
538
|
-
|
539
|
-
sy = sy+my;
|
540
|
-
|
541
|
-
}
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
if(p[sx+mx][sy+my] == turn){
|
546
|
-
|
547
|
-
result = true;
|
548
|
-
|
549
|
-
}else{
|
550
|
-
|
551
|
-
result = false;
|
552
|
-
|
553
|
-
}
|
554
|
-
|
555
|
-
}
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
return result;
|
560
|
-
|
561
|
-
}
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
エラーはactButtonメソッドでnullPointerExceptionです。
|
2
新たに追加したメソッドでエラーが出る
test
CHANGED
File without changes
|
test
CHANGED
@@ -559,3 +559,7 @@
|
|
559
559
|
return result;
|
560
560
|
|
561
561
|
}
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
エラーはactButtonメソッドでnullPointerExceptionです。
|
1
「置けない」マスをクリックしてもボタンが作動しないように新たに2つメソッドを作りましたがうまく動作しません。 追記より下に新たに追加したメソッドを記述します。
test
CHANGED
File without changes
|
test
CHANGED
@@ -314,7 +314,7 @@
|
|
314
314
|
|
315
315
|
|
316
316
|
|
317
|
-
public static void
|
317
|
+
public static void doRev(int sx, int sy){
|
318
318
|
|
319
319
|
|
320
320
|
|
@@ -419,3 +419,143 @@
|
|
419
419
|
|
420
420
|
|
421
421
|
}
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
ー追記ー
|
428
|
+
|
429
|
+
Board classに追加
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
public void actButton(){
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
for(int i=0; i<64; i++)
|
438
|
+
|
439
|
+
{
|
440
|
+
|
441
|
+
int x = i/8;
|
442
|
+
|
443
|
+
int y = i%8;
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
if(Piece.checkRev(x+1,y+1))
|
448
|
+
|
449
|
+
{
|
450
|
+
|
451
|
+
pButton[x][y].addActionListener(this);
|
452
|
+
|
453
|
+
}
|
454
|
+
|
455
|
+
else
|
456
|
+
|
457
|
+
{
|
458
|
+
|
459
|
+
pButton[x][y].addActionListener(null);
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
}
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
Piece classに追加
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
public static boolean checkRev(int sx, int sy){
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
int saveX = sx;
|
478
|
+
|
479
|
+
int saveY = sy;
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
int mx = -1;
|
484
|
+
|
485
|
+
int my = -2; // for文で+1スタートするので-2から始める
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
boolean result = true;
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
for(int i=0; i<8; i++)
|
496
|
+
|
497
|
+
{
|
498
|
+
|
499
|
+
sx = saveX;
|
500
|
+
|
501
|
+
sy = saveY;
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
if(mx == 0 && my == -1)
|
506
|
+
|
507
|
+
{
|
508
|
+
|
509
|
+
my = my + 2;
|
510
|
+
|
511
|
+
}
|
512
|
+
|
513
|
+
else if(my != 1)
|
514
|
+
|
515
|
+
{
|
516
|
+
|
517
|
+
my++;
|
518
|
+
|
519
|
+
}
|
520
|
+
|
521
|
+
else
|
522
|
+
|
523
|
+
{
|
524
|
+
|
525
|
+
mx++;
|
526
|
+
|
527
|
+
my = -1;
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
while(p[sx+mx][sy+my] != turn && p[sx+mx][sy+my] > 0)
|
534
|
+
|
535
|
+
{
|
536
|
+
|
537
|
+
sx = sx+mx;
|
538
|
+
|
539
|
+
sy = sy+my;
|
540
|
+
|
541
|
+
}
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
if(p[sx+mx][sy+my] == turn){
|
546
|
+
|
547
|
+
result = true;
|
548
|
+
|
549
|
+
}else{
|
550
|
+
|
551
|
+
result = false;
|
552
|
+
|
553
|
+
}
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
return result;
|
560
|
+
|
561
|
+
}
|