Ok I really need help with all of this, I have a class named Board.java
The board is represented as a two-dimensional array of char’s. A turtle can leave a trail by writing a character into each position on the board that it passes through.
There will be two constructors for the board. The default constructor takes no arguments and will create a board with 10 rows and 25 columns. Set each element in the board to be a blank space. The second constructor will take two integers that specify the number of rows and the number of columns, respectively. If the number of rows or columns specified is below 1, set the value to 1. If the number of rows or columns specified is greater than 80, set the value to 80. Set each element in the board to be a blank space.
The class will need a clearBoard method. This will put a blank space in every position, except
those positions occupied by turtles. Turtles mark their positions using the characters ‘0’, ‘1’, ‘2’, … ‘9’.
I have the following completed but I am not sure my constructors are right, and I don’t know how to start the clearBoard method. Help please!!
import java.util.Arrays;
public class Board {
private char [][] theBoard;
public Board() { // This will not take any arguments
theBoard = new char [10][25]; //10 rows and 25 columns
for (int row = 0; row < theBoard.length; row++ ) {
for (int col = 0; col < theBoard[row].length; col++ )
theBoard [row][col] = ' ';
System.out.println();
}
}
public Board (int [][] theBoardArray) {
char [][] theBoard = new char [theBoardArray.length] [theBoardArray[0].length];
for (int row = 0; row < theBoard.length; row++ ) {
if (row <1)
row = 1;
else if (row >80)
row =80;
for (int col = 0; col < theBoard[row].length; col++ ){
if (col <1)
col = 1;
else if (col >80)
col =80;
theBoard [row][col] = ' ';
}
System.out.println();
}
}
Fixed some parts, cleaned up a bit and added the rest you want. Explanations are in code comments.