-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethodDataBase.java
More file actions
779 lines (657 loc) · 26.6 KB
/
Copy pathmethodDataBase.java
File metadata and controls
779 lines (657 loc) · 26.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
import java.io.CharArrayReader;
import java.util.ArrayList;
import java.util.Scanner;
public class methodDataBase{
//This is the method database, which holds nearly every method needed in the game class function. Using these methods the pieces can be created and maipulated.
//This method creates the board, by declaring every Piece class object on the board, assigning it's properties, and placing it in the necessary spot on the 2D array.
public static Piece[][] makeBoard(){
/*Declaration of each object on the white team. The first parameter is the type (P for pawn, Q for queen, etc.)
The second is the team that piece is on (W for white, B for black.) */
Piece PW1 = new Piece("P","W");
Piece PW2 = new Piece("P","W");
Piece PW3 = new Piece("P","W");
Piece PW4 = new Piece("P","W");
Piece PW5 = new Piece("P","W");
Piece PW6 = new Piece("P","W");
Piece PW7 = new Piece("P","W");
Piece PW8 = new Piece("P","W");
Piece RW1 = new Piece("R","W");
Piece RW2 = new Piece("R","W");
Piece kW1 = new Piece("k","W");
Piece kW2 = new Piece("k","W");
Piece BW1 = new Piece("B","W");
Piece BW2 = new Piece("B","W");
Piece KW = new Piece("K","W");
Piece QW = new Piece("Q","W");
//Same process, though changing the name, and the team parameter.
Piece PB1 = new Piece("P","B");
Piece PB2 = new Piece("P","B");
Piece PB3 = new Piece("P","B");
Piece PB4 = new Piece("P","B");
Piece PB5 = new Piece("P","B");
Piece PB6 = new Piece("P","B");
Piece PB7 = new Piece("P","B");
Piece PB8 = new Piece("P","B");
Piece RB1 = new Piece("R","B");
Piece RB2 = new Piece("R","B");
Piece kB1 = new Piece("k","B");
Piece kB2 = new Piece("k","B");
Piece BB1 = new Piece("B","B");
Piece BB2 = new Piece("B","B");
Piece QB = new Piece("Q","B");
Piece KB = new Piece("K","B");
//Declares the "empt" type, which is used to identify an empty space.
Piece empt = new Piece("N","N");
/*The board is created as a 2D array, filled solely with the Piece object, which has been created in the Piece class file. Each bracketed section represents a row in the
array, and each index of the internal array is a part of that column. */
Piece[][] board = {
{RW1,kW1,BW1,QW,KW,BW2,kW2,RW2},
{PW1,PW2,PW3,PW4,PW5,PW6,PW7,PW8},
{empt,empt,empt,empt,empt,empt,empt,empt},
{empt,empt,empt,empt,empt,empt,empt,empt},
{empt,empt,empt,empt,empt,empt,empt,empt},
{empt,empt,empt,empt,empt,empt,empt,empt},
{PB1,PB2,PB3,PB4,PB5,PB6,PB7,PB8},
{RB1,kB1,BB1,QB,KB,BB2,kB2,RB2}
};
//Once the board is made, it is returned as a Piece[][].
return board;
}
//This method prints the board out in a visually pleasing and understanding way.
public static String printBoard(Piece[][] b)
{
String prnt = " a b c d e f g h\n\n";
prnt += " -----------------------------------------\n";
/* This nested for loop prints out the board as it currently exists. The internal loop runs through each row and column, with the external loop determining the array to
choose from (1 - 8), and the internal loop prints each element of this array in order. This way each row is printed from top to bottom, running through the array elements.
Some other symbols are printed before and after, as well as between each loop, to create a spacing out of the pieces, and ensuring the output looks like a chess board. */
int x = 1;
for(int i = 0; i < 8; i++)
{
prnt += x + " | ";
for(int j = 0; j <8;j++)
{
//If the space is blank, print a few blank spaces.
if(b[i][j].getType()=="N")
{
prnt+= " " + " | ";
}
else
{
prnt+= b[i][j].getType() + b[i][j].getTeam() + " | ";
}
}
prnt += " " + x;
x += 1;
prnt+="\n -----------------------------------------\n";
}
prnt += "\n a b c d e f g h\n\n";
return prnt;
}
//This method authorizes that the piece selected by the user is valid. It intakes the board, and the piece taken from the user, and ensures that the piece is valid and exists.
public static boolean selectionCheck(Piece[][] b, String strt, String end, boolean whitesTurn)
{
//Converts the
String strt1 = String.valueOf(strt.charAt(0));
int strt2 = Character.getNumericValue(strt.charAt(1));
if (strt.length() != 2 || (!strt1.equals("a") && !strt1.equals("b") && !strt1.equals("c") && !strt1.equals("d") && !strt1.equals("e") && !strt1.equals("f") && !strt1.equals("g") && !strt1.equals("h"))
|| (strt2 != 1 && strt2 != 2 && strt2 != 3 && strt2 != 4 && strt2 != 5 && strt2 != 6 && strt2 != 7 && strt2 != 8))
{
System.out.println("Invalid entry of starting piece.");
return false;
}
int columnArray = 0;
if(strt.charAt(0)=='a')
{
columnArray = 0;
}
if(strt.charAt(0)=='b')
{
columnArray = 1;
}
if(strt.charAt(0)=='c')
{
columnArray = 2;
}
if(strt.charAt(0)=='d')
{
columnArray = 3;
}
if(strt.charAt(0)=='e')
{
columnArray = 4;
}
if(strt.charAt(0)=='f')
{
columnArray = 5;
}
if(strt.charAt(0)=='g')
{
columnArray = 6;
}
if(strt.charAt(0)=='h')
{
columnArray = 7;
}
int rowArray = strt2 - 1;
if(b[rowArray][columnArray].getType().equals("N"))
{
System.out.println("Cannot select empty space");
return false;
}
if((whitesTurn == true) && (b[rowArray][columnArray].getTeam().equals("B")))
{
System.out.println("This piece is not on your team.");
return false;
}
if((whitesTurn == false) && (b[rowArray][columnArray].getTeam().equals("W")))
{
System.out.println("This piece is not on your team.");
return false;
}
String end1 = String.valueOf(end.charAt(0));
int end2 = Character.getNumericValue(end.charAt(1));
if (end.length() != 2 || (!end1.equals("a") && !end1.equals("b") && !end1.equals("c") && !end1.equals("d") && !end1.equals("e") && !end1.equals("f") && !end1.equals("g") && !end1.equals("h"))
|| (end2 != 1 && end2 != 2 && end2 != 3 && end2 != 4 && end2 != 5 && end2 != 6 && end2 != 7 && end2 != 8))
{
System.out.println("Invalid entry of destination piece.");
return false;
}
return true;
}
public static int columnStringToInt(String inputBoardLocation)
{
if(inputBoardLocation.charAt(0) == 'a')
{
return 0;
}
if(inputBoardLocation.charAt(0) == 'b')
{
return 1;
}
if(inputBoardLocation.charAt(0) == 'c')
{
return 2;
}
if(inputBoardLocation.charAt(0) == 'd')
{
return 3;
}
if(inputBoardLocation.charAt(0) == 'e')
{
return 4;
}
if(inputBoardLocation.charAt(0) == 'f')
{
return 5;
}
if(inputBoardLocation.charAt(0) == 'g')
{
return 6;
}
if(inputBoardLocation.charAt(0) == 'h')
{
return 7;
}
else{
return 0;
}
}
public static Piece[][] move(Piece[][] startBoard, String startLocation, String endingLocation)
{
System.out.println(endingLocation);
int endRowArray = (endingLocation.charAt(1)-'0') - 1;
int endColumnArray = columnStringToInt(endingLocation);
int startRowArray = (startLocation.charAt(1)-'0') -1;
int startColumnArray = columnStringToInt(startLocation);
Piece pieceBeingMoved = startBoard[startRowArray][startColumnArray];
startBoard[endRowArray][endColumnArray] = pieceBeingMoved;
startBoard[startRowArray][startColumnArray] = new Piece("N","N");
return startBoard;
}
public static Piece[][] turn(Piece[][] board, Scanner scan, boolean whitesTurn)
{
while(true)
{
System.out.print("\nEnter Starting Position: ");
String startCoord = scan.nextLine();
System.out.print("\nEnter Ending Location: ");
String endCoord = scan.nextLine();
if((selectionCheck(board,startCoord, endCoord, whitesTurn)) && endCheckCentral(startCoord, endCoord, board))
{
return move(board, startCoord, endCoord);
}
}
}
public static void tutorial()
{
System.out.println("\n\nRules:\nThis version of chess is lacking certain elements. The altered rules are as follows:\n\n1. In this version of chess, there is no checkmate.\nThe game will end once a king has been taken down as any other piece would.\n\n2. Pawns who have crossed to the other side of the board are not able to transform into another piece.\n\n3. Pieces are selected using a binary code. The column is typed first, through letters 'a-h'. The row is typed \nsecond, through numbers 1-8. These values are shown on all four sides of the board to help you find the code for the spot you would like to move to.");
}
public static boolean checkForKing(Piece[][] board,String team)
{
Piece kingCheck = new Piece("K",team);
for(int i = 0; i < board.length;i++)
{
for(int j = 0; j < 8;j++)
{
if(board[i][j].getType().equals("K") && board[i][j].getTeam().equals(team))
{
return true;
}
}
}
return false;
}
public static boolean endCheckCentral(String starting, String ending, Piece[][] board)
{
int startRowArray = (starting.charAt(1)-'0') -1;
int startColumnArray = columnStringToInt(starting);
if(board[startRowArray][startColumnArray].getType() == "P")
{
return pawnMoveCheck(starting, ending, board);
}
if(board[startRowArray][startColumnArray].getType() == "R")
{
return rookMoveCheck(starting, ending, board);
}
if(board[startRowArray][startColumnArray].getType() == "k")
{
return knightMoveCheck(starting, ending, board);
}
if(board[startRowArray][startColumnArray].getType() == "B")
{
return bishopMoveCheck(starting, ending, board);
}
if(board[startRowArray][startColumnArray].getType() == "K")
{
return kingMoveCheck(starting, ending, board);
}
else
{
return queenMoveCheck(starting, ending, board);
}
}
public static boolean pawnMoveCheck(String starting, String ending, Piece[][] board)
{
int endRowIndex = (ending.charAt(1)-'0') - 1;
int endColumnIndex = columnStringToInt(ending);
int startRowIndex = (starting.charAt(1)-'0') -1;
int startColumnIndex = columnStringToInt(starting);
if(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam()))
{
System.out.println("You cannot attack your own team.");
return false;
}
if(board[startRowIndex][startColumnIndex].getTeam().equals("W"))
{
if(endRowIndex-startRowIndex!=1)
{
System.out.println("This move is outside the pawn's moveset.");
return false;
}
if(((endColumnIndex-startColumnIndex == 1) || (endColumnIndex-startColumnIndex == -1)) && !(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam())) && !(board[endRowIndex][endColumnIndex].getType().equals("N")))
{
return true;
}
if((endRowIndex-startRowIndex==1) && (board[endRowIndex][endColumnIndex].getType().equals("N")))
{
return true;
}
}
if(board[startRowIndex][startColumnIndex].getTeam().equals("B"))
{
if(endRowIndex-startRowIndex != -1)
{
System.out.println("This move is outside the pawn's moveset.");
return false;
}
if(((endColumnIndex-startColumnIndex == 1) || (endColumnIndex-startColumnIndex == -1)) && !(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam())) && !(board[endRowIndex][endColumnIndex].getType().equals("N")))
{
return true;
}
if((endRowIndex-startRowIndex== -1) && (board[endRowIndex][endColumnIndex].getType().equals("N")))
{
return true;
}
System.out.print("Invalid entry.");
return false;
}
return true;
}
public static boolean rookMoveCheck(String starting, String ending, Piece[][] board)
{
int endRowIndex = (ending.charAt(1)-'0') - 1;
int endColumnIndex = columnStringToInt(ending);
int startRowIndex = (starting.charAt(1)-'0') -1;
int startColumnIndex = columnStringToInt(starting);
if(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam()))
{
System.out.println("You cannot attack your own team.");
return false;
}
if((endRowIndex != startRowIndex)&&(endColumnIndex != startColumnIndex))
{
System.out.println("Invalid move.");
return false;
}
if(endRowIndex > startRowIndex)
{
for(int i = startRowIndex+1; i < endRowIndex;i++)
{
if(!(board[i][endColumnIndex].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
if(endRowIndex < startRowIndex)
{
for(int i = endRowIndex+1; i < startRowIndex;i++)
{
if(!(board[i][endColumnIndex].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
if(endColumnIndex > startColumnIndex)
{
for(int i = startColumnIndex+1; i < endColumnIndex;i++)
{
if(!(board[endRowIndex][i].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
if(endColumnIndex < startColumnIndex)
{
for(int i = endColumnIndex+1; i < endColumnIndex;i++)
{
if(!(board[i][endColumnIndex].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
return true;
}
public static boolean knightMoveCheck(String starting, String ending, Piece[][] board)
{
int endRowIndex = (ending.charAt(1)-'0') - 1;
int endColumnIndex = columnStringToInt(ending);
int startRowIndex = (starting.charAt(1)-'0') -1;
int startColumnIndex = columnStringToInt(starting);
int rowChangeInt = endRowIndex-startRowIndex;
if(rowChangeInt < 0)
{
rowChangeInt = (rowChangeInt * -1);
}
int columnChangeInt = endColumnIndex-startColumnIndex;
if(columnChangeInt < 0)
{
columnChangeInt = (columnChangeInt * -1);
}
if(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam()))
{
System.out.println("You cannot attack your own team.");
return false;
}
if(((rowChangeInt == 2) && (columnChangeInt == 1)) || ((columnChangeInt == 2) && (rowChangeInt == 1)))
{
return true;
}
System.out.println("Invalid move for a knight.");
return false;
}
public static boolean bishopMoveCheck(String starting, String ending, Piece[][] board)
{
int endRowIndex = (ending.charAt(1)-'0') - 1;
int endColumnIndex = columnStringToInt(ending);
int startRowIndex = (starting.charAt(1)-'0') -1;
int startColumnIndex = columnStringToInt(starting);
int rowChangeInt = endRowIndex-startRowIndex;
if(rowChangeInt < 0)
{
rowChangeInt = (rowChangeInt * -1);
}
int columnChangeInt = endColumnIndex-startColumnIndex;
if(columnChangeInt < 0)
{
columnChangeInt = (columnChangeInt * -1);
}
if(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam()))
{
System.out.println("You cannot attack your own team.");
return false;
}
if(columnChangeInt != rowChangeInt)
{
System.out.println("Invalid move.");
return false;
}
//Making sure there are no pieces in the way
//Bishops moving right/down
if((endRowIndex > startRowIndex) && (endColumnIndex > startColumnIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex+1; i < endRowIndex;i++)
{
j += 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
//Bishops moving left/down
if((endRowIndex > startRowIndex) && (endColumnIndex < startColumnIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex+1; i < endRowIndex;i++)
{
j -= 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
//Bishops moving right/up
if((endRowIndex < startRowIndex) && (endColumnIndex > startColumnIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex-1; i > endRowIndex;i--)
{
j += 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
//Bishop moving left/up
if((endColumnIndex < startColumnIndex) && (endRowIndex < startRowIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex-1; i > endColumnIndex;i--)
{
j -= 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
return true;
}
public static boolean kingMoveCheck(String starting, String ending, Piece[][] board)
{
int endRowIndex = (ending.charAt(1)-'0') - 1;
int endColumnIndex = columnStringToInt(ending);
int startRowIndex = (starting.charAt(1)-'0') -1;
int startColumnIndex = columnStringToInt(starting);
int rowChangeInt = endRowIndex-startRowIndex;
if(rowChangeInt < 0)
{
rowChangeInt = (rowChangeInt * -1);
}
int columnChangeInt = endColumnIndex-startColumnIndex;
if(columnChangeInt < 0)
{
columnChangeInt = (columnChangeInt * -1);
}
if(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam()))
{
System.out.println("You cannot attack your own team.");
return false;
}
if((rowChangeInt > 1) || (columnChangeInt > 1))
{
System.out.println("Invalid move.");
return false;
}
return true;
}
public static boolean queenMoveCheck(String starting, String ending, Piece[][] board)
{
int endRowIndex = (ending.charAt(1)-'0') - 1;
int endColumnIndex = columnStringToInt(ending);
int startRowIndex = (starting.charAt(1)-'0') -1;
int startColumnIndex = columnStringToInt(starting);
int rowChangeInt = endRowIndex-startRowIndex;
if(rowChangeInt < 0)
{
rowChangeInt = (rowChangeInt * -1);
}
int columnChangeInt = endColumnIndex-startColumnIndex;
if(columnChangeInt < 0)
{
columnChangeInt = (columnChangeInt * -1);
}
if(board[endRowIndex][endColumnIndex].getTeam().equals(board[startRowIndex][startColumnIndex].getTeam()))
{
System.out.println("You cannot attack your own team.");
return false;
}
//Diagonal moving
//Queen moving right/down
if(rowChangeInt==columnChangeInt)
{
if((endRowIndex > startRowIndex) && (endColumnIndex > startColumnIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex+1; i < endRowIndex;i++)
{
j += 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
//Queen moving left/down
if((endRowIndex > startRowIndex) && (endColumnIndex < startColumnIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex+1; i < endRowIndex;i++)
{
j -= 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
//Queen moving right/up
if((endRowIndex < startRowIndex) && (endColumnIndex > startColumnIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex-1; i > endRowIndex;i--)
{
j += 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
//Queen moving left/up
if((endColumnIndex < startColumnIndex) && (endRowIndex < startRowIndex))
{
int j = startColumnIndex;
for(int i = startRowIndex-1; i > endColumnIndex;i--)
{
j -= 1;
if(!(board[i][j].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
return true;
}
//For parallel Movement
if(columnChangeInt != rowChangeInt)
{
if(endRowIndex > startRowIndex)
{
for(int i = startRowIndex+1; i < endRowIndex;i++)
{
if(!(board[i][endColumnIndex].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
if(endRowIndex < startRowIndex)
{
for(int i = endRowIndex+1; i < startRowIndex;i++)
{
if(!(board[i][endColumnIndex].getType().equals("N")))
{
System.out.println("There is a piece in the way.");
return false;
}
}
}
if(endColumnIndex > startColumnIndex)
{
for(int i = startColumnIndex+1; i < endColumnIndex;i++)
{
if(!(board[endRowIndex][i].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
if(endColumnIndex < startColumnIndex)
{
for(int i = endColumnIndex+1; i < endColumnIndex;i++)
{
if(!(board[i][endColumnIndex].getType().equals("N")))
{
System.out.println("There is a piece in the way");
return false;
}
}
}
return true;
}
return false;
}
}