Question: First to One Game This game is meant for two or more players. In the game, each player starts out with 50 points, as each

First to One Game

This game is meant for two or more players. In the game, each player starts out with 50 points, as each player takes a turn rolling a pair of dice; the amount generated by the dice is subtracted from the player's point. The first player with exactly one point remaining wins. If a player's remaining points minus the amount generated by the dice results in a value less than one, then the amount should be added to the player's points. (As an alternative, the game can be played with a set number turns. In thsi case, the player with the amount of points closest to one, when all rounds have been played, wins.)

Write a program that simulates the game being played by two players. Use the Die class that was presented in Chapter 4 to simulate the dice. Write a player class to simulate the players.

First to One Game This game is meant for two or more

players. In the game, each player starts out with 50 points, as

1 import java.util.Random; sides die with a specified number of 4 The Die class simulates a 7 public class Die 9 private int sides; /Number of sides 10 private int valueThe die's value 12 13 14 15 16 The constructor pexforms an initial roll of the die. The number of sides for the die is passed as an argument. 18 public Die (int numSides) 20 sides numSides; 21 roll () 23 24 25 26 27 28 29 -The roll method simulates the rolling of +the die public void rol1() / Create a Random object Random rand new Random) 31 32 // Get a random value for the die. 34 35 36 + 1; value rand.nextInt (sides) 1 import java.util.Random; sides die with a specified number of 4 The Die class simulates a 7 public class Die 9 private int sides; /Number of sides 10 private int valueThe die's value 12 13 14 15 16 The constructor pexforms an initial roll of the die. The number of sides for the die is passed as an argument. 18 public Die (int numSides) 20 sides numSides; 21 roll () 23 24 25 26 27 28 29 -The roll method simulates the rolling of +the die public void rol1() / Create a Random object Random rand new Random) 31 32 // Get a random value for the die. 34 35 36 + 1; value rand.nextInt (sides)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!