![]() |
Section 8.12.1.23:
|
![]() |
This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.
types SAME = object_type ; $RANDOM_GEN = set of object_type state references : $RANDOM_GEN inv ref_types == forall obj | obj in set ref_types & sub_type($RANDOM_GEN,obj)
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This abstraction models a generator of pseudo-random numbers.
This creation operation produces a new random number generator.
create | : SAME |
create() res : SAME
Since there are no arguments this pre-condition is vacuously true.
Since there are no arguments involved in creating a new generator then this post-condition is also vacuously true.
This creation operation returns a new pseudo-random number generator
This feature initialises the generator with an arbitrary seed provided as argument.
init(self : SAME, seed : CARD)
Since none of the arguments is optional then this pre-condition is vacuously true.
Since the value of the seed merely affects some future value provided by get, the post-condition is true.
This feature initialises the generator with the given seed.
This feature returns the next (pseudo-)random number in the sequence.
get(self : SAME) res : FLTD
Since the self argument is not optional then this pre-condition is vacuously true.
Since the value being returned is random then the post-condition is also true providing that the number yielded conforms to the randomness requirement.
This feature returns the next random number in sequence.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Numeric Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Thursday, 31 May 2001. |
![]() |