Advertisement
LucasSousa

TENTATIVA SCRAMBLE 3X3 I

Nov 25th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. package rascunhos_etc;
  2.  
  3. import java.util.*;
  4.  
  5. public class NewClass {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. Random r = new Random();
  10.  
  11. String[] globalMoves = {"F", "B", "U", "D", "R", "L"};
  12.  
  13. //Arrays classificados (A-Z)
  14. String[] moves1 = {"B", "F"};
  15. String[] moves2 = {"D", "U"};
  16. String[] moves3 = {"L", "R"};
  17.  
  18. String m1 = globalMoves[r.nextInt(6)];
  19.  
  20. String m2 = "";
  21. do {
  22. m2 = globalMoves[r.nextInt(6)];
  23. } while (m2 == m1);
  24.  
  25. int teste = Arrays.binarySearch(moves1, m2); //se value (m2) for encontrado na busca, binarySearch retorna
  26. //o índice do elemento; caso contrário, binarySearch retorna
  27. //um valor negativo.
  28.  
  29. int teste2 = Arrays.binarySearch(moves2, m2);
  30.  
  31. int teste3 = Arrays.binarySearch(moves3, m2);
  32.  
  33. System.out.println(m1 + " " + m2 + "\tSe m2 está contido em moves1: " + teste);
  34.  
  35. System.out.println(m1 + " " + m2 + "\tSe m2 está contido em moves2: " + teste2);
  36.  
  37. System.out.println(m1 + " " + m2 + "\tSe m2 está contido em moves3: " + teste3);
  38.  
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement