Sto provando a creare una sorta di elenco per memorizzare i valori dall'array 'table'. (? Sto usando un ArrayList qui, ma devo essere utilizzando una lista, invece) Tuttavia, ogni volta che provo a compilare, getta il seguente errore:Errore: impossibile trovare il simbolo ArrayList
non riesce a trovare il simbolo simbolo: classe ArrayList location: class players.TablePlayer
Il codice è di sotto.
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>();
}
}
Qualsiasi aiuto sarebbe grande, grazie!
importazione java.util. *; –
Sembra che manchi l'importazione. –
Un IDE Java discreto ti aiuterà in questo. – maba