Question
Another dice game! This game is similar to the Doubles gameshown in class but is called ?HighLow?. This game has two players, you and the
Another dice game! This game is similar to the Doubles gameshown in class but is called ?HighLow?.
This game has two players, you and the computer. Each player hastwo dice and starts with $100. The game begins with a bet from eachuser up to the amount they currently have. The players then rolltheir dice and the player with the higher dice total wins theirbet. The loser loses their bet amount. The game continues as longas you want or until one of the players lose all their money.
To begin creating this game, you are going to create a ?Player?class that encapsulates the amount of money they have and two Dieobjects (use the Die class from the Doubles game). The class willalso have a default constructor that sets the amount of money theyhave to 100 and two functions. The first function, ?roll?, will beused to randomize their dice. The second function, ?total?, will beused to return the total amount of their dice values.
Create a simple program to test your new class and itsfunctions.
package Doubles; import java.util.Random; public class Die { } private int value; public Die() { Roll(); } public void Roll() { } Random random = new Random(); setValue(random.nextInt( bound: 6) + 1); public int getValue() { return value; } public void setValue(int value) { this.value = value; }
Step by Step Solution
3.25 Rating (146 Votes )
There are 3 Steps involved in it
Step: 1
Here is an example of the Player class that you can use to create the HighLow game class Player priv...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