我坚持使用wordSearch程序。我正在尝试使用用户输入的arrayList
中的单词填充二维数组。有人能帮助我吗?
import java.io.* ;
import java.util.ArrayList ;
public class WordSearchPuzzle
{
private char[][] puzzle ;
private ArrayList<String> puzzleWords ;
private int letterCount = 0 ;
private int gridDimensions;
public WordSearchPuzzle(ArrayList<String> userSpecifiedWords)
{
this.puzzleWords = userSpecifiedWords ;
}
private void createPuzzleGrid()
{
int i;
for(i = 0; i < puzzleWords.size() ; i++){
letterCount = puzzleWords.size() + letterCount ;
}
gridDimensions = letterCount * 2;
puzzle = new char[gridDimensions][gridDimensions] ;
}
public void fill() {
int i, j, row, col;
boolean added;
for (i = 0; i < puzzleWords.size(); i++) {
row = (int) (Math.random() * this.gridDimensions);
col = (int) (Math.random() * this.gridDimensions);
added = false;
???