Question: Method evaluate computes the rolled score and adds to the current round score. Write a Java program that will simulate the dice game Pig for
Method evaluate computes the rolled score and adds to the current round score.
Write a Java program that will simulate the dice game Pig for 2 players.
The project must consist of the following classes.
o Class EntryPoint: contains the main method and instantiation of the GameController class; this class has been provided.
o Class GameController: Manages the flow of 2-player game play.
The players must have the option to play as many games as desired.
The user must supply a valid maximum score.
After the goal score is reached by at least one player, the winner and winning score
must be displayed.
Will show total scores after each round of rolls.
o Class PigDice: Holds the state of a set of dice for a player. Scoring must be correct for all combinations of dice.
o Class Die: Represents a standard, fair, 6-sided die.
Simulates a die being rolled.
The face value of the die can be observed without rolling.
Contains the main method. It declares and allocates a GameController object and invokes
the play method.
GameController class
o For example, since the play method controls the game logic, a private method takeTurn (whichtakesthekeyboard Scanner anda PigDice object)shouldcallamethodthat takes a turn for a single player.
o A second private method would maintain functionality to acquire the valid goal score. PigDice Class
This class (1) maintains the Player Pig score for the round, (2) maintains and saves the total Pig score for a player, and (3) provides functionality related to rolling and scoring die. The following methods discuss that functionality in more detail.
Specifications
Die class
Provides all functionality for random number generation and access of the rolled face value.
Must provide an overloaded constructor that, for testing purposes, takes a random number seed.
For testing and submission, use 5 and 10 as seeds to the random number generator.
EntryPoint class
Method play contains the central game control logic.
Use of additional private methods must be used for modularization.
Method currentTotal returns the current total integer score for a game of Pig.
Method currentRound returns the current integer score for a round. Please see input / output
Session 5 for an example differentiating round versus total scores.
Method rollDice simulates rolling two die.
Method lastRoll acquires a formatted string(consistent with the sample session output)
describing the values of the last dice roll.
Method evaluate computes the rolled score and adds to the current round score. lastRoll acquires a formatted string(consistent with the sample session output)
Method save will (1) add the current round score to the total score and (2) clear the current
round score, and (3) return the complete round score.
Method piggedOut returns true / false whether the last roll contained a 1 and ended the roll.
Additional private methods used for modularization:
o Method singleOneRolled returns true / false whether one of the two die resulted in a 1.
o Method doubleOnesRolled returns true / false whether both die rolled a 1.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
