jeudi 26 mai 2016

Generating an array for random numbers

Ok so I am creating an app that allows you to set a timer to a certain length of time and set a number of beeps. when you hit start the timer will play and however many beeps you selected will play at random times. In the code I have an array that I am trying to fill with numbers between 0 and the timer length:

for (int i=0; i< arraysize; i++){
    Random random = new Random();
    beepArray[i] = random.nextInt((0 - count)+ 1);
}

The program can run but it doesnt seem to fill the array with random numbers and so the timer stops and no beeps are played. Have I done something wrong here?

Thanks in adavance Mark




Aucun commentaire:

Enregistrer un commentaire