botgob

Untitled

Jan 28th, 2021
490
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Actor[] shuffleArray(Actor[] oldList){
  2.  
  3.         for (int i = 0; i < oldList.length; i++){
  4.             int randomIndexToSwap = rand.nextInt(oldList.length);
  5.             Actor temp = oldList[randomIndexToSwap];
  6.             oldList[randomIndexToSwap] = oldList[i];
  7.             oldList[i] = temp;
  8.         }
  9.  
  10.         return oldList;
  11.     }
  12.     Actor[] generateDistribution(int length, double[] doubArr){
  13.  
  14.         Actor[] newArray = new Actor[length];
  15.         int amountBlue = 0;
  16.         int amountRed = 0;
  17.         int amountNull = 0;
  18.         for (int i = 0; i < newArray.length; i++) {
  19.             if (amountRed < (int) (doubArr[0] * length)){
  20.                 newArray[i] = new Actor(Color.RED);
  21.                 amountRed++;
  22.             } else if (amountBlue < (int) (doubArr[1] * length)){
  23.                 newArray[i] = new Actor(Color.BLUE);
  24.                 amountBlue++;
  25.             } else if (amountNull < (int) (int) (doubArr[2] * length)){
  26.                 newArray[i] = null;
  27.                 amountNull++;
  28.             }
  29.         }
  30.         shuffleArray(newArray);
  31.         return  newArray;
  32.     }
RAW Paste Data