Question: Dice are used in many tabletop games to implement various game mechanics. Dice come in a variety of shapes and sizes, with four, six, eight,
Dice are used in many tabletop games to implement various game mechanics. Dice come in a variety of shapes and sizes, with four, six, eight, ten, twelve, or twenty sides. Many games need you to assemble a collection of differentsized dice and roll them together. Create a program to imitate dice for a tabletop game.
Create a class for a single dice. The constructor should accept an integer that indicates how many sides the die has. The class should include a function that simulates rolling the die and returns a random number from the valid range.
Create another class that represents a pool of dice. This class should include functions for adding or removing a die from the pool. The class should also include a function that rolls all of the dice in the pool and returns the total that was rolled.
All commands
add
add
roll
roll
add
roll
roll
roll
rollall
add
add
remove
rollall
remove
remove
remove
add
rollall
Exit
Sample inputoutput:
Enter Command:
add
Adding Dice
Enter Command:
add
Adding Dice
Enter Command:
roll
Dice Roll Result:
Enter Command:
roll
Dice Roll Result:
Enter Command:
add
Adding Dice
Enter Command:
roll
Dice Roll Result:
Enter Command:
roll
Dice Roll Result:
Enter Command:
roll
Dice Roll Result:
Enter Command:
rollall
Rolling all Dice:
Dice : Roll Result:
Dice : Roll Result:
Dice : Roll Result:
Summation of all rolls:
Enter Command:
add
Adding Dice
Enter Command:
add can you please solve it in C# starter code: namespace MyDicePool
public class Dice
public int Side get; private set;
private static Random r;
static Dice
r new Random;
public Diceint side
Side side;
public string Roll
ToDo
Please complete this method
return ;
public override string ToString
ToDo
Please complete this method
return ;
public class DicePool
TODO create DicePool classes
public List DiceList get; private set; new List;
public DicePool
public void AddDiceint side
ToDo
Please complete this method
public bool RemoveDiceint side
ToDo
Please complete this method
return false;
public string RollAllDice
ToDo
Please complete this method
return ;
public override string ToString
return RollAllDice;
class Program
static void Mainstring args
DicePool dicePool new DicePool;
string command;
do
Console.WriteLineEnter Command:";
command Console.ReadLine;
command command.Trim;
command command.ToLower;
string split command.Split;
if split "adddice" split "add"
int sides int.Parsesplit;
Console.WriteLine$"Adding Dice sides;
dicePool.AddDicesides;
else if split "remove"
int sides int.Parsesplit;
Console.WriteLine$"Removing Dice sides;
Console.WriteLine$"Remove Successful: dicePoolRemoveDicesides;
else if split "roll"
int sides int.Parsesplit;
Dice dice dicePool.DiceList.Findd dSide sides;
if dice null
Console.WriteLine$"Dice dice Roll Result: diceRoll;
else
Console.WriteLineDice not found...
Cannot roll this dice!";
else if split "rollall"
Console.WriteLineRolling all Dice:";
Console.WriteLine
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
