For this task I have to

Create a new 2D boolean array that has the same size as the

parameter array.

Implement the reproduction rules to fill in the new array

based on the parameter array

return the new array

Rules of game of life is

Any live cell with fewer than two live neighbours dies, as if caused by under-population.

Any live cell with two or three live neighbours lives on to the next generation.

Any live cell with more than three live neighbours dies, as if by overcrowding.

Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

I'm stuck on programming, this a piece of code I've done for the first rule and a a bit on the second

public static boolean[][] nextGeneration(boolean[][] board1) { boolean [][] newBoard; if (board[row][column] == "*" && count < 2) { newBoard[row][column] = board[row][column]; newBoard[row][column] ="."; } else if (board[r][c] == "*" && count== 2) { newBoard[row][column] = board[row][column]; newBoard[row][column] ="*"; }

I'm having so much trouble understanding coding, i used to vairable board instead of board1 because I already assigned for board as you see here

public static int countNeighbours(boolean[][] board, int row, int col) { int count = 0; if (row -1 >= 0 && col -1 >= 0) { if (board[row-1][col-1] == true) {count++;} } if (row -1 >= 0 && col > 0) { if (board[row-1][col] == true){count++;}} if (row -1 >= 0 && col + 1 > 1) { if (board[row-1][col+1] == true){count++;}} if (row > 0 && col - 1 >= 0) { if (board[row][col-1] == true){count++;}} if (row > 0 && col + 1 > 1) { if (board[row][col+1] == true){count++;}} if (row + 1 > 0 && col -1 >= 0) { if (board[row+1][col-1] == true){count++;}} if (row + 1 > 1 && col > 0) { if (board[row+1][col] == true){count++;}} if (row + 1 > 0 && col + 1 > 1) { if (board[row+1][col+1] == true){count++;}} return count; }

obviously board doesn't work in my coding since board1 is defined not board, but i'm soo confused on what to assign, can you please explain to me and help give me a solution to my problem. all opinions welcomed