So I am trying to write a method that populate a board in a game. I am just beginning to learn about programming so I do not know much about special methods.
public static void Board(char[][] array){
for(int i=0; i<2*array.length+1; i++) {
if(i %2 ==0){
for(int j=0; j<2*array.length+1;j++){
if(j%2==0){
System.out.print("+");
}
else{
System.out.print("-");
}
}
}
else {
for(int j=0; j<2*array.length+1;j++){
if(j%2==0){
System.out.print("|");
}
else{
System.out.print(" "); // Maybe should use this spot to insert the x and o from the array.
}
}
}
System.out.println();
But in the board, where I currently have empty spaces, I want to actually be able to accept input.
For example , if
char [][] b={{'',' x',' ',},{' ','s','t '},{'o','o',' '}};
Board(a);
Then instead of only having the empty spaces, I would like the element corresponding to the array to go there. I marked on my code where I think this might be done. I don't know of any special methods, but possibly DeepArray to string or such. I understand how to import using Arrays.ToString, the issue is with the index.