These methods should ask for the size of the array (without error) then every element in the array should be false (without error) and at the end the array should be printed... but I get an exception in the line 29 (it is marked in the code)
I am initializing the array so I don't really know whats wrong with my code.
private boolean[][] board; // true = queen, false = empty
[...]
private void determineBoardSize(){
write("Sprechen sie sich ab wer weiß und wer schwarz ist");
write("weiß muss eine Zahl zwischen 5 und 8 wählen");
nrRows = readInt("Zahl aus {5,6,7,8}");
if(nrRows < 5 || nrRows > 8) determineBoardSize();
write("Schwarz muss nun eine Zahl zwischen ErsteZahl -1 und ErsteZahl + 1 wählen");
nrColumns = readInt("eine Zahl zwischen ErsteZahl -1 und ErsteZahl + 1 wählen");
if(nrColumns < nrRows - 1 || nrColumns > nrRows + 1) determineBoardSize();
private void initBoard(){
boolean[][] board = new boolean[nrRows][nrColumns];
for(int i = 0; i < nrRows; i++){
for(int y = 0; y < nrColumns; y++){
board[i][y] = false;
}
}
}
private void printBoard(){
for (int j = board[0].length - 1; j >= 0; j--) { //java.lang.NullPointerException
System.out.print("\n " + (1 + j));
for (int i = 0; i < board.length; i++) {
System.out.print(board[i][j] ? " X" : " -");
}
}
System.out.print("\n ");
for (int i = 1; i <= board.length; i++) {
System.out.print(" " + i);
}
System.out.println("\n" + (whiteToMove ? white : black) + " ist am Zug.");
}
public void startGame(){
determineBoardSize();
initBoard();
determineFirstPlayer();
printBoard();
mainLoop();
reportWinner();
}
public static void main(String[] args) {
Dame ds = new Dame("Weiß", "Schwarz");
ds.startGame();
}