-1
I have the following method:
void selecionarBloco() {
while (blocoSelecionadoCorretamente == false) {
System.out.print("Qual casa você irá marcar (" + jogador +"):");
int blocoSelecionado = teclado.nextInt();
if (blocos[blocoSelecionado].equals("X") || blocos[blocoSelecionado].equals("O")) {
System.out.println("BLOCO JÁ SELECIONADO!");
blocoSelecionadoCorretamente = false;
} else {
blocoSelecionadoCorretamente = true;
blocos[blocoSelecionado] = jogador;
}
}
}
When I put it to work the game of a very strange bug making 9 moves automatically and giving draw. I wonder what’s wrong.
Method: As long as the lockSelected is false, it will do the following commands, ask the user for a home, and place it inside lockSelected, after which it will test them to see if the selected house is already occupied, if yes it returns lockSelectionCorrectly = false, if not lockCorrectly = true, ending the method.