






Hotspots: Admin Pages | Turn-in Site |
Current Links: Case 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
- Case last edited on 29 July 2009 at 11:50 pm by c-76-97-208-233.hsd1.ga.comcast.net
- Index of Individual Cases last edited on 28 July 2009 at 3:01 pm by lwc029.ats.gatech.edu