Question
How can I create a rolling dice game in C# where: - the dice needs to have Max property (indicates the number of faces the
How can I create a rolling dice game in C# where:
- the dice needs to have Max property (indicates the number of faces the dice has -6 by default. This property should be initialized using the constructor. Max number will be used while rolling the dice to generate a random number between 1 and the value of Max property) and Face property should be read-only as its value will be assigned randomly when the Roll method is called.
- It also should have Enum, used to determine the result of rolling multiple dices (Jackpot (all the dice have the max number), Win (all the dice have the same number, but not the max), or Lose (different numbers).
- It needs to have a class for players with 3 properties: Name, Score and History (is a list of enum type. It should be used to save the history of the player rolls. It should be initialized by the constructor).
- The functionality of the game must include: class constructor (should take care of initializing a new game, this includes: Initializing players list to become ready to add new players and creating new set of dice (based on an argument based to the constructor) and add them to the Dice list. Assume we are using a 6 faces dice). AddPlayer() method (Once the game starts, its not allowed to add new players). Start() method (starts the game. It can be called once 2 players at least are added to the game. This method should update a game state to mention that the game has started (so AddPlayer cant be called anymore) and setup the ActivePlayer property to the first player in the players list). PlayTurn() method to Roll the dice by calling the Roll method for each dice in the Dice list, calculate the turn score, update the player score and history and setup the next player. UpdatePlayerStat() method should update the player score and history based on the active player, score and the roll result. TheWinner() method should return the player who got the most score. It should return null if all the scores are the same. The property IsGameover is a read-only property. It should return true if the game is over. The game ends when 6 turns are played by each player or one player gets 2 jackpots (all dices are 6).
The UML is as follow:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started