hi everybody, i'm a student and i'm sick of going around this. lol
i have to make a game of tic tac toe, and i did everything, and everything is working fine exept this. this is a method to see if there is a victory in a line, it does all that, see's the possibilitys, and only writes when there's actually a victory, but the problem is, it's supose to return a boolean vic that if true the game stops(allready made in another method) if false does nothing(it's in another method). but in this case it's allways returning false, how do i make it return true?
here's the code!
public static boolean testVictoriaLinha(char []posicaoNoTabuleiro){
boolean vic=false;
int sizeBoard = (int) Math.sqrt(posicaoNoTabuleiro.length);
for(int i=0; i<posicaoNoTabuleiro.length; i=i+sizeBoard){
if(posicaoNoTabuleiro[i]=='X'||posicaoNoTabuleiro[i]=='O'){ //it only enters the if(vic) if in those positions
vic=true; //theres a X or O;
}
for(int j=0; j<sizeBoard-1; j++){
if(posicaoNoTabuleiro[i+j]!=posicaoNoTabuleiro[i+j+1]){// se if the positions are diferent
vic=false;
break;
}
}
if(vic){
Tabuleiro tabuleiro = new Tabuleiro();
tabuleiro.board(posicaoNoTabuleiro);
System.out.println();
System.out.println("victoria1 "+posicaoNoTabuleiro[i] );
}
}
return vic;//it is supose to return vic insted is returning false allways false
}
thanks!