mirror of
https://gitlab.com/tutorial-java-rafa-munoz/tutorial-java-2024-25/tutorialjava2024-25.git
synced 2025-11-09 18:03:09 +01:00
11
This commit is contained in:
@@ -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 {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user