samedi 7 février 2015

Scala Random Number

Ok, I understand how to implement a random number generator in Scala and how to set the upper bound for the random number being generated, but I am confused as how to change the lower bound. For example:



var computerGuess= scala.util.Random
var higher=100
var computerGuessInt=computerGuess.nextInt(higher)


will let the computer generate a random number from 0 to 100.


But I want to change the lower bound to be, say 29 so that the computer could pick a random number from 29 to 100. How can I do this?





Aucun commentaire:

Enregistrer un commentaire