Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

According to the following Code : We have the following IDice interface and DiceEvaluator class: public interface IDice { int Next(); } public class DiceEvaluator

According to the following Code :

We have the following IDice interface and DiceEvaluator class:

public interface IDice {

int Next();

}

public class DiceEvaluator {

static public void Evaluate(IDice d) {

double sum = 0f;

int[] times = new int[7];

for (int i=0;i<100;i++) {

int roll = d.Next();

if (roll <= 0 || roll > 6) {

Console.WriteLine("Bad dice! No evaluation done.");

}

times[roll]++;

sum += roll;

}

double average = sum/100;

Console.WriteLine("Dice roll average of 100 runs: {0}",average);

Console.WriteLine("Statistics: ");

for (int i=1;i<=6;i++) {

Console.WriteLine("{0} : {1}",i,times[i]);

}

}

Implement a RiggedDice that also implements the IDice interface in the above code. In RiggedDice, you have 50% chance to actually get a 6, and a uniform chance to get 1 to 5 otherwise. Use the DiceEvaluator to check on the final Dice performance.

Copy and paste the final RiggedDice class here:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago