Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set<Point> set = new HashSet<Point>();
- Random position = new Random();
- Point test=new Point();
- do{
- test.x=position.nextInt(xx);
- test.y=position.nextInt(yy);
- //xx and yy are the random number limits called from another part of the code
- set.add(test);
- }
- while (set.size()<number);
- List<Object> list = new ArrayList<Object>(set);
- Object[] coord = list.toArray();
- Set<Point> set = new HashSet<Point>();
- Random position = new Random();
- Point test;
- do{
- test = new Point();
- test.x=position.nextInt(xx);
- test.y=position.nextInt(yy);
- //xx and yy are the random number limits called from another part of the code
- set.add(test);
- }
- while (set.size()<number);
- List<Object> list = new ArrayList<Object>(set);
- Object[] coord = list.toArray();
- do{
- test = new Point();
- test.x=position.nextInt(xx);
- test.y=position.nextInt(yy);
- //xx and yy are the random number limits called from another part of the code
- set.add(test);
- }
- while (set.size()<number);
- Random rndm = new Random();
- String[] selectedNumber = new String[15];
- String[] sequanceNumber = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"};
- //*****FIRST LOOP START*****//
- for(byte a = 0; a < 15;){
- int temp = rndm.nextInt(15)+1;
- //*****SECOND LOOP START*****//
- for(byte b = 0; b < 15; b++){
- String s4 = temp+"";
- //*****CHECKING CONDITION START*****//
- if(s4.equals(sequanceNumber[b]) ){
- selectedNumber[a] = s4;
- String s1 = sequanceNumber[b];
- s1 = s1.replace(s1, " ");
- sequanceNumber[b] = s1;
- a++;
- }
- //*****CHECKING CONDITION END*****//
- }
- //*****SECOND LOOP END*****//
- }
- //*****FIRST LOOP END*****//
- //*****PRINT ALL RANDOM VALUES BUT NOT REPEATED VALUES*****//
- System.out.println(Arrays.toString(selectedNumber));
- //*****FIRST LOOP START*****//
- for(byte a = 0; a < 15;){
- int temp = rndm.nextInt(15)+1;
- //*****SECOND LOOP START*****//
- for(byte b = 0; b < 15; b++){
- String s4 = temp+"";
- //*****CHECKING CONDITION START*****//
- if(s4.equals(sequanceNumber[b]) ){
- selectedNumber[a] = s4;
- String s1 = sequanceNumber[b];
- s1 = s1.replace(s1, " ");
- sequanceNumber[b] = s1;
- a++;
- }
- //*****CHECKING CONDITION END*****//
- }
- //*****SECOND LOOP END*****//
- }
- //*****FIRST LOOP END*****//
- //*****PRINT ALL RANDOM VALUES BUT NOT REPEATED VALUES*****//
- System.out.println(Arrays.toString(selectedNumber));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement