Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!