0 8, , , . , (?) . , . List<Integer> , . , @Mureinik answer:
class TicTacToeCells {
private static final int MAX_CELLS = 9;
private List<Integer> cells;
private Random random;
public void init() {
random = new Random();
cells = new ArrayList<Integer>(MAX_CELLS);
for (int i = 0; i < MAX_CELLS; ++i) {
numbers.add(i);
}
}
public boolean canPickCell(int cellToPick) {
return cells.contains(cellToPick);
}
public int pickCellByComputer() {
int index = random.nextInt(cells.size());
return cells.get(index);
}
public void pickCell(int cellToPick) {
cells.remove(cellToPick);
}
}