






Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Random number generator in SmallTalk - Hubert Liu
At first I had no idea how to use random numbers in SmallTalk, but after some research, there's an easy way to do it.
For your viewing pleasure, here's some VERY helpful code:
|gen max|
gen := FastRandom new.
max := 10.
((gen next*max+1) + 1)floor.
This will generate a random integer between 1 and 10.
If you want to generate a random integer between 5 and 10, you will have to set the max to 5, and shift the number generated by 5. For example...
|gen max|
gen := FastRandom new.
max := 5.
((gen next* max+1) + 5)floor.
Will generate an integer from 5 to 10.
Hope this helps in the future, as it was difficult for our group to find this information.
Links to this Page
- Cases last edited on 30 July 2011 at 2:33 am by r59h132.res.gatech.edu
- Index of Individual Cases last edited on 3 May 2011 at 12:46 pm by r52h48.res.gatech.edu