The following is a short snippet of code that simulates rolling a 6-sided dice 100 times. There… 1 answer below »

The following is a short snippet of code that simulates rolling a 6-sided dice 100 times. There is an equal chance of rolling any digit from 1 to 6.

Create your own class, Loaded Dice,that is derived from Random. The constructor for Loaded Dice needs to only invoke Random’s constructor. Override the public int next Int(int num) method so that with a 50% chance, your new method always returns the largest number possible (i.e., num – 1), and with a 50% chance, it returns what Random ’s next Int method would return.

You do not need to change the print Dice Rolls method even though it takes a parameter of type Random. Polymorphism tells Java to invoke Loaded Dice‘s nextInt() method instead of Random ’s nextInt() method.

 

 

 

 

Looking for a Similar Assignment? Hire our Top Uk Tutors while you enjoy your free time! All papers are written from scratch and are 100% Original. Try us today! Active Discount Code FREE15