mirror of
https://gitlab.com/tutorial-java-rafa-munoz/tutorial-java-2024-25/tutorialjava2024-25.git
synced 2025-11-09 09:57:40 +01:00
11
This commit is contained in:
@@ -10,24 +10,19 @@ public class TresEnRaya {
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// int t[][] = new int[3][3];
|
||||
int t[][] = new int[][] {{2, 1, 1},
|
||||
{1, 2, 2},
|
||||
{2, 2, 0}};
|
||||
int t[][] = new int[3][3];
|
||||
// int t[][] = new int[][] {{2, 1, 1},
|
||||
// {1, 2, 2},
|
||||
// {2, 2, 0}};
|
||||
int turno = 1;
|
||||
|
||||
// inicializaTablero(t);
|
||||
|
||||
inicializaTablero(t);
|
||||
do {
|
||||
// Muestro tablero
|
||||
imprimieTablero(t);
|
||||
|
||||
// Pido jugada a jugador (turno)
|
||||
pidoJugadaAJugador(t, turno);
|
||||
|
||||
// Cambiar turno
|
||||
turno = cambiaTurno(turno);
|
||||
|
||||
} while (ganadorDelJuego(t) == 0 && !hayEmpate(t));
|
||||
|
||||
// Imprimo ganador o empate
|
||||
@@ -61,7 +56,14 @@ public class TresEnRaya {
|
||||
*/
|
||||
public static void imprimieTablero(int t[][]) {
|
||||
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 {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user