Exercises in this lecture  previous -- Keyboard shortcut: 'p'        Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 3.7
Sharing the Random Generator


In the Die class shown in the start of this lecture, each Die object creates its own Random object.

We observed that tosses of two or more instances of class Die will be identical. Explain the reason of this behavior.

Modify the Die class such that all of them share a single Random object. Consider different ways to implement this sharing. Rerun the Die program and find out if "the parallel tossing pattern" observed above has been alleviated.


Solution