Overview Write a program that will simulate the dice game Pig for 2 players. 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 Cass 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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Java

**Overview**

Write a program that will simulate the dice game *Pig* for 2 players.

**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 dice.
  - 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`.
Transcribed Image Text:**Overview** Write a program that will simulate the dice game *Pig* for 2 players. **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 dice. - 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`.
**Educational Website Text Transcription and Explanation**

---

**Game Specifications and Design Overview**

The primary objective of the game is to allow players to engage in as many rounds as desired while maintaining valid scoring and offering clear game feedback.

- **Gameplay Requirements:**
  - Players choose the number of games they wish to participate in.
  - A valid maximum score must be supplied by the user.
  - Upon reaching the predetermined goal score by any player, the game displays the winner and their score.
  - The game will display total scores after each round.

- **Class Implementations:**
  - **PigDice Class:** 
    - Manages the state of a player's set of dice.
    - Ensures scoring accuracy for all possible dice combinations.

  - **Die Class:** 
    - Represents a standard, fair, 6-sided die.
    - Simulates dice rolling and reports the die's face value without needing a roll to view it.

**Specifications**

- **Die Class:**
  - Provides functions for random number generation and accessing the die's rolled face value.
  - Includes an overloaded constructor for test purposes, accepting a random number seed.
  - Testing and submission should use seeds 5 and 10 for the random number generator.

- **EntryPoint Class:**
  - Hosts the `main` method.
  - Declares and allocates a `GameController` object and calls the `play` method.

- **GameController Class:**
  - The `play` method contains core game control logic.
  - Modularization through additional private methods is required.
    - Example: A `takeTurn` method manages a single player's turn using the `Scanner` and `PigDice` objects.
    - Another method should handle acquiring the valid goal score.

- **PigDice Class Methodology:**
  - Manages the Player Pig score for each round, saves the total Pig score for a player, and handles the dice rolling and scoring.
  - Key Methods:
    - `currentTotal`: Returns the total score for the game.
    - `currentRound`: Provides the round's score, distinguishing it from total score.
    - `rollDice`: Simulates rolling of two dice.
    - `evaluate`: Computes rolled scores and adds to the current score.
    - `lastRoll`: Returns formatted string output of the last dice roll.
    - `save`: Adds the round score to the total, clears the round score, and returns the
Transcribed Image Text:**Educational Website Text Transcription and Explanation** --- **Game Specifications and Design Overview** The primary objective of the game is to allow players to engage in as many rounds as desired while maintaining valid scoring and offering clear game feedback. - **Gameplay Requirements:** - Players choose the number of games they wish to participate in. - A valid maximum score must be supplied by the user. - Upon reaching the predetermined goal score by any player, the game displays the winner and their score. - The game will display total scores after each round. - **Class Implementations:** - **PigDice Class:** - Manages the state of a player's set of dice. - Ensures scoring accuracy for all possible dice combinations. - **Die Class:** - Represents a standard, fair, 6-sided die. - Simulates dice rolling and reports the die's face value without needing a roll to view it. **Specifications** - **Die Class:** - Provides functions for random number generation and accessing the die's rolled face value. - Includes an overloaded constructor for test purposes, accepting a random number seed. - Testing and submission should use seeds 5 and 10 for the random number generator. - **EntryPoint Class:** - Hosts the `main` method. - Declares and allocates a `GameController` object and calls the `play` method. - **GameController Class:** - The `play` method contains core game control logic. - Modularization through additional private methods is required. - Example: A `takeTurn` method manages a single player's turn using the `Scanner` and `PigDice` objects. - Another method should handle acquiring the valid goal score. - **PigDice Class Methodology:** - Manages the Player Pig score for each round, saves the total Pig score for a player, and handles the dice rolling and scoring. - Key Methods: - `currentTotal`: Returns the total score for the game. - `currentRound`: Provides the round's score, distinguishing it from total score. - `rollDice`: Simulates rolling of two dice. - `evaluate`: Computes rolled scores and adds to the current score. - `lastRoll`: Returns formatted string output of the last dice roll. - `save`: Adds the round score to the total, clears the round score, and returns the
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education