嗨,我是 Java 新手,在创建我的单词搜索拼图程序时遇到了困难。我正在尝试让用户输入单词的 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] ;
}
private void generateWordSearchPuzzle()
{
}
public void fillPuzzle()
{
int i, j, r;
for (i = 0; i < this.gridDimensions; i++)
for (j = 0; j < this.gridDimensions; j++)
if (puzzle[i][j] == ' ') {
r = (int) (Math.random() * letterCount);
puzzle[i][j] = letterCount.charAt(r);
}
}
public void fill()
{
int i, j, gridDimensions, r, c;
boolean added;
this.clear();
for (i = 0; i < WordSearch.words.size(); i++) {
ws = (WSWord) WordSearch.words.elementAt(i);
row = (int) (Math.random() * this.rows);
col = (int) (Math.random() * this.cols);
added = false;
}