Overview

This is a short lab (so you have some time to work on Project 1) that gives you a little experience with using inheritance to add functionality.

Step 1: Random means random

Copy the following program:

Compile and run it. You should see a random-looking sequence of 70 integers inthe range 1..6. Look closely, and take note of any consecutive occurences of the same number, e.g. 55 or 22. It's possible that you might run this and not find a repetition, but extremely unlikely!

Step 2: Modifying/extending Random

Suppose you wanted to produce sequences of random-looking numbers subject to the constraint that no consecutive numbers in the sequence could be the same? Your job is to create a new class NRRandom (Non-Repeating Random) that works this way. Specificially, you will use inheritance to create the class NRRandom that behaves exactly like Random does, except that calls to nextInt(int n) never produce the same number on consecutive calls. If you do this properly, the original Lab05, modified only by replacing Random with NRRandom, should give us what we want. I.e. the following program:

should produce a random-looking sequence of 70 integers in the range 1..6, with no repeated numbers in consecutive positions.

Note: You must use inheritance to do this, and if you do it right, your solution should be short and sweet. You'll definitely want to look at the Java API documentation for class Random.
Note: It's important that you do your own testing! Run your program several times and ensure that you never see repeated numbers, but in all other ways the numbers you get seem random!

Submission

submit -c=IC211 -p=lab05 NRRandom.java