This commit is contained in:
Rafa Muñoz
2024-11-11 11:22:31 +01:00
parent dbeea11b71
commit 0e3d50092e

View File

@@ -10,24 +10,19 @@ public class TresEnRaya {
* @param args * @param args
*/ */
public static void main(String[] args) { public static void main(String[] args) {
// int t[][] = new int[3][3]; int t[][] = new int[3][3];
int t[][] = new int[][] {{2, 1, 1}, // int t[][] = new int[][] {{2, 1, 1},
{1, 2, 2}, // {1, 2, 2},
{2, 2, 0}}; // {2, 2, 0}};
int turno = 1; int turno = 1;
inicializaTablero(t);
// inicializaTablero(t);
do { do {
// Muestro tablero // Muestro tablero
imprimieTablero(t); imprimieTablero(t);
// Pido jugada a jugador (turno) // Pido jugada a jugador (turno)
pidoJugadaAJugador(t, turno); pidoJugadaAJugador(t, turno);
// Cambiar turno // Cambiar turno
turno = cambiaTurno(turno); turno = cambiaTurno(turno);
} while (ganadorDelJuego(t) == 0 && !hayEmpate(t)); } while (ganadorDelJuego(t) == 0 && !hayEmpate(t));
// Imprimo ganador o empate // Imprimo ganador o empate
@@ -61,7 +56,14 @@ public class TresEnRaya {
*/ */
public static void imprimieTablero(int t[][]) { public static void imprimieTablero(int t[][]) {
System.out.println("\nTablero actual: "); System.out.println("\nTablero actual: ");
UtilsArrays.imprimeMatriz(t);
for (int i = 0; i < t.length; i++) {
for (int j = 0; j < t[i].length; j++) {
System.out.print( (t[i][j] != 0)? (t[i][j] == 1)? "X" : "O" : "-");
System.out.print("\t");
}
System.out.println();
}
} }
/** /**
@@ -157,5 +159,3 @@ public class TresEnRaya {