I have a piece of code:
public void setBoardMemberPosition() {
int[] position = null;
do{
positionX = RandomNumberGenerator.generateRandomNumber(Board.DIMENSION);
positionY = RandomNumberGenerator.generateRandomNumber(Board.DIMENSION);
position = new int[] { positionX, positionY };
} while(checkIfPositionIsOccupied(position));
board.setElementAt(positionX, positionY, name);
storedMembers.add(position);
}
Can someone explain to me why the elements are not being added to the list, where:
private ArrayList<int[]> storedMembers = new ArrayList<int[]>();is a Class variable and:checkIfPositionIsOccupied(position) returns true/false
if (storedMembers.contains(position))
i have a feeling its something to do with the do while, ive debugged it with no luck.