i want to import an array, but i cant..
i have my chess class.. and one method that tries to check whether there is a check.
basically like this..
if(pieces[columnStartN][rowStartN].isMoveValid(columnStartN,rowStartN,columnEndN,rowEnd) && pieceDevour){
pieces[columnStartN][rowStartN]=null;
pieces[columnStartN][rowStartN]=pieces[columnEndN][rowEnd];
}
rowStartN=rowEnd;
columnStart=columnEnd;
int kingRow=0;
int kingColumn=0;
chessPiece="BKing";
int c=0;
int pieceColumn=0;
int pieceRow=0;
for(int column=0;column<pieces.length;column++){
for(int row=0;column<pieces[row].length;row++){
if(pieces[column][row].FindPiece(chessPiece).equals(chessPiece));// gets the king position...
pieces[kingColumn][kingRow]=pieces[column][row];
}
}
if(pieces[columnStartN][rowStartN].isKingThreatened(columnEndN,rowEnd,kingColumn,kingRow)){// the method here sends arguments to the method in a pieces' class. to check whether its next move threatens the king (check).
// however i cant import this array:
ChessPiece pieces[][];
pieces =new ChessPiece[7][7];// pieces[][] cant be imported
pieces[1][0]=new Pawn("Bpn1");
pieces[1][1]=new Pawn("Bpn2");
pieces[1][2]=new Pawn("Bpn3");
pieces[1][3]=new Pawn("Bpn4");
pieces[1][4]=new Pawn("Bpn5");
pieces[1][5]=new Pawn("Bpn6");
pieces[1][6]=new Pawn("Bpn7");
pieces[1][7]=new Pawn("Bpn8");
pieces [0][0]=new Rook("BR1");
pieces [0][1]=new Knight("BN1");
pieces [0][2]=new Bishop("BB1");
pieces [0][3]=new King("BKing");
pieces [0][4]=new Queen("BQueen");;
pieces [0][5]=new Bishop("BB2");
pieces [0][6]=new Knight("BN2");
pieces [0][7]=new Rook("BR2");
pieceDevour=true;
}
package il.co.Bishop;
import il.co.ChessInterface.ChessPiece;
ChessPiece [][] pieces=new ChessPiece[7][7];
public boolean isKingThreatened(int columnEndN,int rowEnd, int kingRow, int kingColumn) {
boolean valid = false;
for(int i=rowEnd;i<pieces.length;i++)
for(int j=columnEndN;j<pieces[i].length;j++)
if(pieces[i][j]!=null && pieces[i][j]==pieces[kingColumn][kingRow])
valid=true;
else
valid=false;
System.out.println("Check: Pawn Threatens king");
return valid;
}
for now , my code is limited cause i made another new array, that can identify the pieces position compare to the king, but cant see where the rest of the pieces stand.
how do i import pieces [?][?] array in class chessInterface to a pieces class (Bishop in this example..)