I have a method in which I go through a char array, what I need is to go through the array and when I find the character I'm looking for, add a counter, the method enters but the condition of when the counter has a certain number is not met print a message and exit the method.
Here is my code:
public class Tablero {
public static void validarColumna(char array[][]) {
int contx = 0;
int conty = 0;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
if (array[i][j] == 'X') {
contx++;
conty =0;
if (contx == 4) {
System.out.println("Linea!! Ganador Jugador 1");
return;
}
}else if (array[i][j] == 'Y') {
conty++;
contx=0;
if (conty == 4) {
System.out.println("Linea!! Ganador Jugador 1");
return;
}
}
}
}
}