I have been working on this project for a while now and I still can't figure out the first part of it. I am trying to make a grid of letters to make a word search, but I can't seem to figure out how to print it. So far I have:
public wordsearch(int row, int col, String letters){
if (letters.length()== row*col){
gridletters= letters;
gridrow=row;
gridcol=col;
letters= letters.toUpperCase();
String array[][]= new String[row][col];
int character=0;
for(int rowNum =0; rowNum<row; rowNum++){
for(int colNum=0; colNum<col; colNum++){
array[rowNum][colNum] = letters.charAt(character) + "";
character++;
}
}
}
}
and then I have to print it using a toString method, but I can't access the array in the toString.
enpublic String toString(){
String grid= "";
for(int index=0; index<gridrow; index++){
for(int index2=0; index2<gridcol; index2++){
grid+= array[index][index2]+ " ";
}
grid+= "\n";
}
return grid;
}
someone help please?