lundi 8 août 2016

How to randomly assign unique array elements to randomly selected enum values

I have created an enum for three different types of balls small (sBall), medium (mBall) and large (lBall). Also I have an array of Int's (posArray) representing positions. How can I randomly select 1-9 balls and randomly select unique positions from my Int array (posArray is [0, 1, ...,8]) for each the randomly selected balls? Please see the enum below

enum BallTypes: Int  {
   case sBall = 0, mBall, lBall
}




Aucun commentaire:

Enregistrer un commentaire