home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
RiscOS
/
APP
/
DEVS
/
SMALLT
/
GNUST.ZIP
/
GnuSt
/
Demos
/
RandomInte
< prev
Wrap
Text File
|
1991-09-13
|
536b
|
32 lines
"By Andy Valencia (uunet!sequent!vandys)"
"A source of random integers"
Integer subclass: #RandomInteger
instanceVariableNames: ''
classVariableNames: 'Source'
poolDictionaries: ''
category: nil.
!
RandomInteger comment:
'My instances are random integers'
!
!RandomInteger class methodsFor: 'instance creation'!
new
^ self error: 'Must use between:and:'
!
between: low and: high
| i range |
(Source = nil) ifTrue: [ Source _ Random new ].
range _ high - low.
i _ (((Source next) * (range + 1)) + low) rounded.
^ i
!!