My problem is I'm trying to make a console based chess game. Starting off with an Object array to hold the squares of the chess board.
class Chessboard {
Object[][] board = new Object[10][10];
I fill it out perfectly with various if-sentences like this:
for (int i = 0; i < 10; i++) {
for (int j = 0;j < 10; j++) {
if a position on a chess demands a specific piece:
board[i][j] = new ChessPiece(String firstLetterOfPiece, i, j);
else fill in blanks:
board[i][j] = new ChessPiece(" ", i,j);
}
}
Now, I have some find position methods in the ChessPiece class that just gives a compiler error when I try it from the class Chessboard.
What I do is: (to test)
System.out.println(board[2][4].getXposition());
I get "Cannot find symbol". What can I do to avoid this?
Stringdoing in your pseudocode in thenew ChessPiecector call?ChessPiece[][] board = new ChessBoard[10][10]? And why are you using a 10x10 grid? A "moat" doesn't make a lot of sense here.