Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. Set<Point> set = new HashSet<Point>();
  2. Random position = new Random();
  3. Point test=new Point();
  4.  
  5. do{
  6. test.x=position.nextInt(xx);
  7. test.y=position.nextInt(yy);
  8. //xx and yy are the random number limits called from another part of the code
  9. set.add(test);
  10. }
  11. while (set.size()<number);
  12.  
  13. List<Object> list = new ArrayList<Object>(set);
  14. Object[] coord = list.toArray();
  15.  
  16. Set<Point> set = new HashSet<Point>();
  17. Random position = new Random();
  18. Point test;
  19.  
  20. do{
  21. test = new Point();
  22. test.x=position.nextInt(xx);
  23. test.y=position.nextInt(yy);
  24. //xx and yy are the random number limits called from another part of the code
  25. set.add(test);
  26. }
  27. while (set.size()<number);
  28.  
  29. List<Object> list = new ArrayList<Object>(set);
  30. Object[] coord = list.toArray();
  31.  
  32. do{
  33. test = new Point();
  34. test.x=position.nextInt(xx);
  35. test.y=position.nextInt(yy);
  36. //xx and yy are the random number limits called from another part of the code
  37. set.add(test);
  38. }
  39. while (set.size()<number);
  40.  
  41. Random rndm = new Random();
  42. String[] selectedNumber = new String[15];
  43. String[] sequanceNumber = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"};
  44.  
  45. //*****FIRST LOOP START*****//
  46. for(byte a = 0; a < 15;){
  47.  
  48. int temp = rndm.nextInt(15)+1;
  49.  
  50. //*****SECOND LOOP START*****//
  51. for(byte b = 0; b < 15; b++){
  52.  
  53. String s4 = temp+"";
  54.  
  55. //*****CHECKING CONDITION START*****//
  56. if(s4.equals(sequanceNumber[b]) ){
  57.  
  58.  
  59. selectedNumber[a] = s4;
  60.  
  61. String s1 = sequanceNumber[b];
  62. s1 = s1.replace(s1, " ");
  63. sequanceNumber[b] = s1;
  64.  
  65. a++;
  66.  
  67. }
  68. //*****CHECKING CONDITION END*****//
  69.  
  70.  
  71. }
  72. //*****SECOND LOOP END*****//
  73.  
  74.  
  75. }
  76. //*****FIRST LOOP END*****//
  77.  
  78.  
  79. //*****PRINT ALL RANDOM VALUES BUT NOT REPEATED VALUES*****//
  80. System.out.println(Arrays.toString(selectedNumber));
  81. //*****FIRST LOOP START*****//
  82. for(byte a = 0; a < 15;){
  83.  
  84. int temp = rndm.nextInt(15)+1;
  85.  
  86. //*****SECOND LOOP START*****//
  87. for(byte b = 0; b < 15; b++){
  88.  
  89. String s4 = temp+"";
  90.  
  91. //*****CHECKING CONDITION START*****//
  92. if(s4.equals(sequanceNumber[b]) ){
  93.  
  94. selectedNumber[a] = s4;
  95. String s1 = sequanceNumber[b];
  96. s1 = s1.replace(s1, " ");
  97. sequanceNumber[b] = s1;
  98. a++;
  99.  
  100. }
  101. //*****CHECKING CONDITION END*****//
  102. }
  103. //*****SECOND LOOP END*****//
  104. }
  105. //*****FIRST LOOP END*****//
  106.  
  107.  
  108. //*****PRINT ALL RANDOM VALUES BUT NOT REPEATED VALUES*****//
  109. System.out.println(Arrays.toString(selectedNumber));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement