Guest User

Untitled

a guest
Apr 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Rompecabezas {
  4.  
  5.  
  6. final static String UNO = "I";
  7. final static String DIEZ = "X";
  8. final static String CINCO = "V";
  9. final static String WHITE = "▓";
  10.  
  11. String tablero[][] ;
  12.  
  13.  
  14.  
  15.  
  16. public static void main(String[] argvs)
  17. {
  18.  
  19. Rompecabezas r = new Rompecabezas();
  20. r.tablero = new String[5][5];
  21. r.llenartablero();
  22. //r.imprimirTablero();
  23. r.shuffle();
  24. //r.Menu();
  25. //Scanner kb = new Scanner(System.in);
  26. r.imprimirTablero();
  27.  
  28. }
  29.  
  30.  
  31. public void shuffle()
  32. {
  33. int i, j,k,l;
  34.  
  35. for(int t = 0; t<6; t++)
  36. {
  37. String tmp;
  38.  
  39. i= (int)(Math.random()*5);
  40. j= (int)(Math.random()*5);
  41. k= (int)(Math.random()*5);
  42. l= (int)(Math.random()*5);
  43.  
  44. tmp= tablero[i][j];
  45. tablero[i][j]= tablero[k][l];
  46. tablero[k][l]= tmp;
  47.  
  48. }
  49. }
  50.  
  51. public void imprimirTablero()
  52. {
  53.  
  54. for(int i = 0 ; i<5; i++)
  55. {
  56. for(int j= 0; j<5; j++)
  57. {
  58. System.out.print(tablero[i][j] + "\t");
  59. }
  60. System.out.println("\n");
  61. }
  62. }
  63.  
  64. public void llenartablero()
  65. {
  66. tablero[0][0]= UNO;
  67. tablero[0][1]= UNO + UNO;
  68. tablero[0][2]= UNO + UNO + UNO;
  69. tablero[0][3]= UNO + CINCO;
  70. tablero[0][4]= CINCO;
  71.  
  72. tablero[1][0]= CINCO + UNO;
  73. tablero[1][1]= CINCO + UNO + UNO;
  74. tablero[1][2]= CINCO + UNO + UNO + UNO;
  75. tablero[1][3]= UNO + DIEZ;
  76. tablero[1][4]= DIEZ;
  77.  
  78. tablero[2][0]= DIEZ + UNO;
  79. tablero[2][1]= DIEZ + UNO + UNO;
  80. tablero[2][2]= DIEZ + UNO + UNO;
  81. tablero[2][3]= UNO + DIEZ + CINCO;
  82. tablero[2][4]= DIEZ + CINCO;
  83.  
  84. tablero[3][0]= CINCO + UNO;
  85. tablero[3][1]= CINCO + UNO + UNO;
  86. tablero[3][2]= CINCO + UNO + UNO + UNO;
  87. tablero[3][3]= UNO + DIEZ;
  88. tablero[3][4]= DIEZ;
  89.  
  90. tablero[4][0]= DIEZ + CINCO + UNO;
  91. tablero[4][1]= DIEZ + CINCO + UNO + UNO;
  92. tablero[4][2]= DIEZ + CINCO + UNO + UNO + UNO;
  93. tablero[4][3]= UNO + DIEZ + DIEZ;
  94. tablero[4][4]= WHITE;
  95. }
  96.  
  97. public void Menu()
  98. {
  99. System.out.println("\t\tPresione W para mover hacia arriba");
  100. System.out.println("\t\tPresione S para mover hacia abajo");
  101. System.out.println("\t\tPresione A para mover hacia izquierda");
  102. System.out.println("\t\tPresione D para mover hacia derecha");
  103. System.out.println("\t\tPresione N para un juego nuevo");
  104. System.out.println("\t\tPresione F finalizar");
  105. }
  106.  
  107.  
  108. }
Add Comment
Please, Sign In to add comment