@Test public void printEmptyBoard() { Board board = new Board(3, 3); Assert.assertEquals("Expected another board", "0 0 0\n0 0 0\n0 0 0", board.toString()); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (int row = 0; row < getRows(); row++) { for (int col = 0; col < getCols(); col++) { sb.append(getCellSate(row, col)); sb.append(col + 1 == getCols() ? "\n" : " "); } } return sb.toString().trim(); }
Board implements Cloneable { @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int row = 0; row < getRows(); row++) { for (int col = 0; col < getCols(); col++) { sb.append(getCellSate(row, col)); sb.append(col + 1 == getCols() ? "\n" : " "); } } return sb.toString().trim(); } }
Board implements Cloneable { @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int row = 0; row < getRows(); row++) { for (int col = 0; col < getCols(); col++) { sb.append(getCellSate(row, col)); sb.append(col + 1 == getCols() ? "\n" : " "); } } return sb.toString().trim(); } Board(int rows, int cols);  Board(int[][] board); }
Board implements Cloneable { @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int row = 0; row < getRows(); row++) { for (int col = 0; col < getCols(); col++) { sb.append(getCellSate(row, col)); sb.append(col + 1 == getCols() ? "\n" : " "); } } return sb.toString().trim(); } Board(int rows, int cols);  Board(int[][] board); void setCellState(int row, int col, int state); int getCellSate(int row, int col); boolean areValidCoordinates(int row, int col); int getTotalSize(); int getRows(); int getCols(); boolean isBottomRightAlive(int row, int col); boolean isBottomAlive(int row, int col); boolean isBottomLeftAlive(int row, int col); boolean isRightAlive(int row, int col); boolean isLeftAlive(int row, int col); boolean isTopRightAlive(int row, int col); boolean isTopAlive(int row, int col); boolean isTopLeftAlive(int row, int col); int getAliveNeighbours(int row, int col); @Override Board clone(); @Override String toString(); }
Board implements Cloneable { @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int row = 0; row < getRows(); row++) { for (int col = 0; col < getCols(); col++) { sb.append(getCellSate(row, col)); sb.append(col + 1 == getCols() ? "\n" : " "); } } return sb.toString().trim(); } Board(int rows, int cols);  Board(int[][] board); void setCellState(int row, int col, int state); int getCellSate(int row, int col); boolean areValidCoordinates(int row, int col); int getTotalSize(); int getRows(); int getCols(); boolean isBottomRightAlive(int row, int col); boolean isBottomAlive(int row, int col); boolean isBottomLeftAlive(int row, int col); boolean isRightAlive(int row, int col); boolean isLeftAlive(int row, int col); boolean isTopRightAlive(int row, int col); boolean isTopAlive(int row, int col); boolean isTopLeftAlive(int row, int col); int getAliveNeighbours(int row, int col); @Override Board clone(); @Override String toString();  }