我正在尝试创建某种列表来存储数组'table'中的值.(我在这里使用arraylist,但是我应该使用列表吗?)但是,每次我尝试编译时,都会抛出以下错误:
找不到符号符号:class ArrayList location:class players.TablePlayer
代码如下.
public class TablePlayer extends Player {
int[][] table;
ArrayList goodMoves;
public TablePlayer(String name) {
super(name);
}
@Override
public int move() {
int oppLast = opponentLastMove();
int myLast = myLastMove();
if (!isLegalMove(oppLast)) {
return 0; // temporary
}
if (wonLast()) {
table[oppLast][myLast] = 1;
table[myLast][oppLast] = -1;
}
if ((wonLast() == false) && (oppLast != myLast)) {
table[oppLast][myLast] = -1;
table[myLast][oppLast] = 1;
}
for (int i = 0; i < table.length; i++) {
for (int j = 0; j < table.length; j++) {
if (table[i][j] == 1) {
goodMoves.add(table[i][j]);
}
}
}
return oppLast; // temporary
}
@Override
public void start() {
int[][] table = new int[7][7];
ArrayList<int> goodMoves = new ArrayList<int>();
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒,谢谢!
mrk*_*rks 20
你在文件的顶部有一个import语句吗?
import java.util.ArrayList;
Run Code Online (Sandbox Code Playgroud)