Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ajedrez {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int X, Y;
- char[][] tablero = generarTablero(10,10);
- System.out.println("Simularemos movimientos de un caballo de ajerdrez");
- System.out.println("A continuación debe ingresar las coordenadas iniciales");
- X = Helper.getPositiveInt("Ingrese fila: ");
- while(X<0|X>9){
- System.out.println("Debe estar entre 0 y 9");
- X = Helper.getPositiveInt("Ingrese fila: ");
- }
- Y = Helper.getPositiveInt("Ingrese columna: ");
- while(Y<0|Y>9){
- System.out.println("Debe estar entre 0 y 9");
- Y = Helper.getPositiveInt("Ingrese columna: ");
- }
- CaballoAjedrez horse = new CaballoAjedrez(X,Y);
- for (int i = 0; i<5; i++ ) {
- horse.mostrarTablero(tablero);
- horse.mover(tablero);
- }
- }
- private static char[][] generarTablero(int filas, int columnas) {
- char[][] tablero = new char[filas][columnas];
- for (int i = 0; i < filas; i++) {
- for (int j = 0; j < columnas; j++) {
- tablero[i][j] = '-'; // Inicializar todo el tablero con espacios en blanco
- }
- }
- return tablero;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement