Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Rompecabezas {
- final static String UNO = "I";
- final static String DIEZ = "X";
- final static String CINCO = "V";
- final static String WHITE = "▓";
- String tablero[][] ;
- public static void main(String[] argvs)
- {
- Rompecabezas r = new Rompecabezas();
- r.tablero = new String[5][5];
- r.llenartablero();
- //r.imprimirTablero();
- r.shuffle();
- //r.Menu();
- //Scanner kb = new Scanner(System.in);
- r.imprimirTablero();
- }
- public void shuffle()
- {
- int i, j,k,l;
- for(int t = 0; t<6; t++)
- {
- String tmp;
- i= (int)(Math.random()*5);
- j= (int)(Math.random()*5);
- k= (int)(Math.random()*5);
- l= (int)(Math.random()*5);
- tmp= tablero[i][j];
- tablero[i][j]= tablero[k][l];
- tablero[k][l]= tmp;
- }
- }
- public void imprimirTablero()
- {
- for(int i = 0 ; i<5; i++)
- {
- for(int j= 0; j<5; j++)
- {
- System.out.print(tablero[i][j] + "\t");
- }
- System.out.println("\n");
- }
- }
- public void llenartablero()
- {
- tablero[0][0]= UNO;
- tablero[0][1]= UNO + UNO;
- tablero[0][2]= UNO + UNO + UNO;
- tablero[0][3]= UNO + CINCO;
- tablero[0][4]= CINCO;
- tablero[1][0]= CINCO + UNO;
- tablero[1][1]= CINCO + UNO + UNO;
- tablero[1][2]= CINCO + UNO + UNO + UNO;
- tablero[1][3]= UNO + DIEZ;
- tablero[1][4]= DIEZ;
- tablero[2][0]= DIEZ + UNO;
- tablero[2][1]= DIEZ + UNO + UNO;
- tablero[2][2]= DIEZ + UNO + UNO;
- tablero[2][3]= UNO + DIEZ + CINCO;
- tablero[2][4]= DIEZ + CINCO;
- tablero[3][0]= CINCO + UNO;
- tablero[3][1]= CINCO + UNO + UNO;
- tablero[3][2]= CINCO + UNO + UNO + UNO;
- tablero[3][3]= UNO + DIEZ;
- tablero[3][4]= DIEZ;
- tablero[4][0]= DIEZ + CINCO + UNO;
- tablero[4][1]= DIEZ + CINCO + UNO + UNO;
- tablero[4][2]= DIEZ + CINCO + UNO + UNO + UNO;
- tablero[4][3]= UNO + DIEZ + DIEZ;
- tablero[4][4]= WHITE;
- }
- public void Menu()
- {
- System.out.println("\t\tPresione W para mover hacia arriba");
- System.out.println("\t\tPresione S para mover hacia abajo");
- System.out.println("\t\tPresione A para mover hacia izquierda");
- System.out.println("\t\tPresione D para mover hacia derecha");
- System.out.println("\t\tPresione N para un juego nuevo");
- System.out.println("\t\tPresione F finalizar");
- }
- }
Add Comment
Please, Sign In to add comment