Tablero

mail@pastecode.io avatar
unknown
java
a month ago
1.3 kB
3
Indexable
Never
public class Tablero {
	int filas = 8;
	int columnas = 8;
	String[][] tablero = new String[filas][columnas];

	public void imprimirTablero() {
		for (int i = 0; i < 8; i++) {
			switch (i) {
			case 0:
				tablero[0][i] = "Tn";
				tablero[7][i] = "Tb";
				break;
			case 1:
				tablero[0][i] = "Cn";
				tablero[7][i] = "Cb";
				break;
			case 2:
				tablero[0][i] = "An";
				tablero[7][i] = "Ab";
				break;
			case 3:
				tablero[0][i] = "rn";
				tablero[7][i] = "rb";
				break;
			case 4:
				tablero[0][i] = "Rn";
				tablero[7][i] = "Rb";
				break;
			case 5:
				tablero[0][i] = "An";
				tablero[7][i] = "Ab";
				break;
			case 6:
				tablero[0][i] = "Cn";
				tablero[7][i] = "Cb";
				break;
			case 7:
				tablero[0][i] = "Tn";
				tablero[7][i] = "Tb";
				break;
			}
		}
		for (int j = 0; j < 8; j++) {
			tablero[1][j] = "Pn";
			tablero[6][j] = "Pb";
		}
		System.out.println("    A    B     C    D    E    F   G    H");
		for (int i = 0; i < tablero.length; i++) {
			System.out.print(i + 1 + " | ");
			for (int j = 0; j < tablero[i].length; j++) {
				System.out.print(tablero[i][j] + " | ");
			}
			for (int k = 2; k < 6; k++) {
				for (int j = 0; j < 8; j++) {
					tablero[k][j] = "  ";
				}
			}
			System.out.println();
		}
	}
}
Leave a Comment