Preciso criar um método que vai percorrendo células procurando um determinado valor (6), se não encontrar esse valor eu quero que ele retorne true e se encontrar eu quero que retorne false.
Método:
public boolean verifyFinish() {
boolean finish = false;
if (turn.equals(Turn.White)){
for (int x = 0; x < 8; x++){
for (int y = 0; y < 8; y++){
int king = 0; king = pecas.getCell(x, y); System.err.println(x+","+y+"="+king); if (king != 6){
finish = true;
}
}
}
}
return finish;
}
Poderia ser assim, pois não chega nada a esse método.
Você acha q funciona?
public boolean verifyFinish() {
boolean finish = false;
if (turn.equals(Turn.White)){
int [] x = new int[8];
for (int i = 0; i < x.length; x++){
int [] y = new int[8];
for (int j = 0; j < y.length; j++){
int king = 0; king = pecas.getCell(x[i], y[j]); if (king != 6){
finish = true;
}
}
}
}
return finish;
}
Acho que você está com um certo problema de lógica no seu código.
Perceba que você está tentando pegar os valores de uma tabela (acho eu), só que em lugar algum está definindo as células dessa tabela.
Você está usando para isso as variáveis x e y, que são criadas DENTRO do loop, portanto, contendo ZEROS. A menos que a célula na coordenada 0,0 tenha o valor 6, o método SEMPRE retornará false.