Background: Game Rules The rules to the (dice) game of Pig:  You will need 2 dice.  To Play: a. The players each take turns rolling two die. b. A player scores the sum of the two dice thrown (unless the roll contains a 1): If a single number 1 is thrown on either die, the score for that whole turn is lost (referred to as “Pigged Out”). A 1 on both dice is scored as 25. c. During a single turn, a player may roll the dice as many times as they desire. The score for a single turn is the sum of the individual scores for each dice roll. d. The first player to reach the goal score wins unless a player scores higher subsequently in the same round. Therefore, everyone in the game must have the same number of turns. Execution and User Input This program is quite interactive with the user(s) and will take in the following information; please review the sample input / output sessions for details; we describe them again here emphasizing input. The program will prompt for the number of points the game will be played to (1-100). Once a valid goal score has been entered the game will “roll” the dice for the first player by randomly selecting the valid values 1 thru 6 for each of the two dice. The score will be displayed and the player will be prompted to continue their turn by rolling the die again (unless they have “pigged out” by rolling a single 1). The player will have the option of continuing or ending the turn by entering ‘y’ for Yes. When Player 1 completes their turn, Player 2 will engage the exact same way. At the conclusion of both player’s turns the total score for each will be compared to the goal score to determine if the game has ended. If the goal score has not been reached, then the game continues with both players taking their turn in sequence. Once one or both of the players reaches the goal score the game ends and the results are displayed. The game may end in a tie. At the conclusion of a game, the program will prompt whether a new game shall be played: ‘y’ for Yes. Requirements • The name of the Java Project must be Project3. • Generally, user input must not be case sensitive. • 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. 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  Contains the main method. It declares and allocates a GameController object and invokes the play method. GameController class  Method play contains the central game control logic.  Use of additional private methods must be used for modularization. o For example, since the play method controls the game logic, a private method takeTurn (which takes the keyboard Scanner and a PigDice object) should call a method that 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.  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 evaluate computes the rolled score and adds to the current round score.  Method lastRoll acquires a formatted string (consistent with the sample session output) describing the values of the last dice roll.  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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Background: Game Rules 
The rules to the (dice) game of Pig: 
  You will need 2 dice. 
  To Play: 
a.  The players each take turns rolling two die. 
b.  A player scores the sum of the two dice thrown (unless the roll contains a 1): If a single 
number 1 is thrown on either die, the score for that whole turn is lost (referred to as 
“Pigged Out”). A 1 on both dice is scored as 25. 
c.  During a single turn, a player may roll the dice as many times as they desire. The score 
for a single turn is the sum of the individual scores for each dice roll. 
d.  The first player to reach the goal score wins unless a player scores higher subsequently in 
the same round. Therefore, everyone in the game must have the same number of turns. 
Execution and User Input 
This program is quite interactive with the user(s) and will take in the following information; please review 
the sample input / output sessions for details; we describe them again here emphasizing input. 
The program will prompt for the number of points the game will be played to (1-100). 
Once  a  valid goal  score  has  been  entered  the  game  will  “roll” the  dice  for the first  player  by  randomly 
selecting the valid values 1 thru 6 for each of the two dice. The score will be displayed and the player will 
be prompted to continue their turn by rolling the die again (unless they have “pigged out” by rolling a single 
1). 
The player will have the option of continuing or ending the turn by entering ‘y’ for Yes. 
When Player 1 completes their turn, Player 2 will engage the exact same way. 
At  the  conclusion  of  both  player’s  turns  the  total  score  for  each  will  be  compared  to  the  goal  score  to 
determine if the game has ended. If the goal score has not been reached, then the game continues with both 
players taking their turn in sequence. Once one or both of the players reaches the goal score the game ends 
and the results are displayed. The game may end in a tie. 
At the conclusion of a game, the program will prompt whether a new game shall be played: ‘y’ for Yes. 
 
Requirements 
 
•  The name of the Java Project must be Project3. 
•  Generally, user input must not be case sensitive. 
•  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. 
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 
  Contains the main method. It declares and allocates a GameController object and invokes 
the play method. 
GameController class 
  Method play contains the central game control logic. 
  Use of additional private methods must be used for modularization. 
o  For example, since the play method controls the game logic, a private method takeTurn 
(which takes the keyboard Scanner and a PigDice object) should call a method that 
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. 
  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 evaluate computes the rolled score and adds to the current round score.  
  Method lastRoll acquires a formatted string (consistent with the sample session output) 
describing the values of the last dice roll. 
  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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY