Tablero.java 1.57 KB
Newer Older
roshka committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
public class Tablero{
    Html archivo;
    
    final String arribaYBase = "| - - - | - - - | - - - |" ;

    public Tablero(){
        this.archivo = new Html();
    }

    public void imprimirTableroVacio(){
        System.out.println("   1   2   3  ");
        for(int j = 0;j<3;j++){
            System.out.println(" " + arribaYBase);
            System.out.print(j+1);
            System.out.println("|       |       |       |");
        System.out.println(" " + arribaYBase);
        }
    }

    public void imprimirTablero(char[][] temporal){
        for(int i = 0;i<3;i++){
            System.out.println(arribaYBase);
            System.out.println("|   " + temporal[i][0] + "   "+ "|   " + temporal[i][1] + "   " + "|   " + temporal[i][2] + "   |");
        }
        System.out.println(arribaYBase);
    }

    public void imprimirTableroArchivo(char[][] temporal){
        String impTabla[][] = new String[3][3];
        for(int i = 0;i<3;i++){
            this.archivo.escribirLineaJuego(arribaYBase);
            for(int j = 0;j < 3;j++){
                if(temporal[i][j] == ' '){
                    impTabla[i][j] = "&nbsp";
                }else{
                    impTabla[i][j] = "" + temporal[i][j];
                }
            }
            this.archivo.escribirLineaJuego("|&nbsp&nbsp&nbsp" + impTabla[i][0] + "&nbsp&nbsp&nbsp"+ "|&nbsp&nbsp&nbsp" + 
                impTabla[i][1] + "&nbsp&nbsp&nbsp" + "|&nbsp&nbsp&nbsp" + impTabla[i][2] + "&nbsp&nbsp&nbsp|");
        }
        this.archivo.escribirLineaJuego(arribaYBase);
    }

}