# IN JAVA: This game is meant for two or more players., Each player starts out with 50 points, as each player takes a turn rolling the dic…..

We offer all "help with my paper" services e.g. Custom essay writing, Dissertation writing help, Research paper writing, and Term paper writing services at affordable prices. We cover all your paper help needs 24/7.
Get started Order in Chat
97.5
Orders delivered on time
120
4.9/5
Average rating

IN JAVA: This game is meant for two or more players., Each player starts out with 50 points, as each player takes a turn rolling the dice; the amount generated by the dice is subtracted from the player’s points. 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 a alternative, the game can be played with a set number of turns. In this 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 6 to simulate the dice. Write a Player class to simulate the player. Enter the player’s names and display the die rolls and the totals after each round.

THIS IS THE DIE CLASS: please complete entire program and upload screenshot of output along with the answer.

import java.util.Random;

/**
The Die class simulates a six-sided die.
*/

public class Die
{
private int sides; // Number of sides
private int value; // The die’s value

/**
The constructor performs an initial
roll of the die.
@param numSides The number of sides for this die.
*/

public Die(int numSides)
{
sides = numSides;
roll();
}

/**
The roll method simlates the rolling of
the die.
*/

public void roll()
{
// Create a Random object.
Random rand = new Random();

// Get a random value for the die.
value = rand.nextInt(sides) + 1;
}

/**
getSides method
@return The number of sides for this die.
*/

public int getSides()
{
return sides;
}

/**
getValue method
@return The value of the die.
*/

public int getValue()
{
return value;
}
}

OUTPUT SHOULD BE SOMETHING LIKE:

———————————

Round 1:

player1 rolled a 6

player2 rolled a 4

player1 has 44 points

player2 has 46 points

player1 wins.———————————-

import java.io.*;
import java.util.*;

class Die
{
private int sides;
private int value;

public Die(int numSides)
{
sides = numSides;
roll();
}

public void roll()
{
// Create a Random object.
Random rand = new Random();

// Get a random value for the die.
value = rand.nextInt(sides) + 1;
}

public int getSides()
{
return sides;
}

public int getValue()
{
return value;
}
}

class Player{

private String name;
private int score;
private Die die;
public Player(String a){
name = a;
score = 50;
die = new Die(6);
}
public int roll(){
die.roll();
return (die.getValue());
}
public void modifyScore(int a){
if ((score – a) < 1)
score = score + a;
else
score = score -a;
}
public int getScore(){
return score;
}
public String getName(){
return name;
}

}

public class DemoGame {
public static void main(String[] args){
int s1,s2;
int diff1, diff2;
String name1 , name2;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter Player 1 Name:”);
name1 = sc.next();
System.out.println(“Enter Player 2 Name:”);
name2 = sc.next();

Player p1 = new Player(name1);
Player p2 = new Player(name2);
int count = 1;
while (p1.getScore() != 1 && p2.getScore() != 1){
System.out.println(“—————————–“);
System.out.println(“Round ” + count + “:”);
s1 = p1.roll();
p1.modifyScore(s1);
System.out.println(p1.getName() + ” rolled a ” + s1);
diff1 = p1.getScore() – 1;
s2 = p2.roll();
p2.modifyScore(s2);
System.out.println(p2.getName() + ” rolled a ” + s2);
diff2 = p2.getScore() – 1;
System.out.println(p1.getName() + ” has ” + p1.getScore() + ” points”);
System.out.println(p2.getName() + ” has ” + p2.getScore() + ” points”);
if (diff1 == diff2){
System.out.println(“It is a tie”);
}
else {
if (diff1 < diff2){
System.out.println(p1.getName() +” wins”);
}
else {
System.out.println(p2.getName() + ” wins”);
}
}
count++;
}

}
}

Quality Guaranteed

With us, you are either satisfied 100% or you get your money back-No monkey business

Too much stress and so little time?
Our experts are ready to help
Place order
Why Choose Us
Expert writers
Our rigorous writer selection procedure ensures that only subject-matter experts with master's degrees and higher work on your assignments.
Confidentiality
Your personal information is not shared with any third parties. Neither do writers have access to it.
Affordable prices
My Paper Support is a cheap do my paper service that offers high quality papers at amazing prices. Our customers enjoy lifetime discounts and other offers
Original content
All papers are written from scratch and plagiarism is not tolerated. We scan all papers for plagiarism using Copyscape, Turniting and Safe Assign
Here's why students opt for MyPaper Support
Hiring a professional "do my paper" service is a guaranteed method of balancing academic, family, and professional demands.
Pressed for time
Working smart
Confidentiality
Busy Schedule
We understand that balancing professional and student roles is an onerous task. As a result, we have tailored our services to help you balance the increasing demands without tainting the integrity of our education system. Get your paper done within tight deadlines of up to 4 hours.
Speedy delivery. You will receive your
Get started Order in Chat
Raise the GPA
Our paper writers have helped thousands of students improve their GPA and advance professionally. We have a robust QA team which ensures that no error goes unnoticed. Join us and get that Summa cum laude.
Accurate papers. Your work will be based on reputable
sources that provide factual information on the topic.
Get started Order in Chat
Career growth
Why should you stagnate in one position yet you have the required experience to advance professionally? Most students use our do my paper service to obtain the much-needed papers to complement their experience and advance in career.
Ownership of final product You can use the delivered
samples in any way you choose.
Get started Order in Chat
Professional do my paper service
At MyPaper Support, we take your privacy seriously and that why students love us. No writer has access to your personal information. What happens here, stays here..
Value for money. We will return your money
if you are not satisfied with the result.
Get started Order in Chat
Check Prices
Pages (550 words)
\$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know that being a student these days is hard. Because of this, our prices are some of the lowest on the market.

Instead, we offer perks, discounts, and free services to enhance your experience.
Sign up, place your order, and leave the rest to our professional paper writers in less than 2 minutes.
step 1
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
s
Get personalized services with My Paper Support
One writer for all your papers
You can select one writer for all your papers. This option enhances the consistency in the quality of your assignments. Select your preferred writer from the list of writers who have handledf your previous assignments
Same paper from different writers
Are you ordering the same assignment for a friend? You can get the same paper from different writers. The goal is to produce 100% unique and original papers
Copy of sources used
Our homework writers will provide you with copies of sources used on your request. Just add the option when plaing your order
What our partners say about us
We appreciate every review and are always looking for ways to grow. See what other students think about our do my paper service.
Human Resources Management (HRM)
Thanks for your assistance and promptness.
Customer 452701, November 1st, 2022
Nursing
Work is always perfectly done.
Customer 452707, January 11th, 2024
Nursing
Not all sources were " American sources" as directed
Customer 452615, September 16th, 2021
Other
Awesome Work!
Customer 452587, February 24th, 2022
Technology
Excelled job on the paper!
Customer 452885, December 28th, 2022
Other
GREAT
Customer 452813, July 3rd, 2022
Social Work and Human Services
The paper is impressive. Very professional and per the instructions
Customer 452533, May 24th, 2021
Human Resources Management (HRM)
Thanks. I am very pleased with my paper.
Customer 452701, August 1st, 2023
Human Resources Management (HRM)
The paper was delivered on time and I am very pleased with the writer's work.
Customer 452701, June 21st, 2023
IT, Web
Paper was great and accomplished everything I needed.
Customer 452885, October 27th, 2022
Technology
Excellent job on the paper!
Customer 452885, December 28th, 2022
Human Resources Management (HRM)
Thanks
Customer 452701, August 22nd, 2023
Enjoy affordable prices and lifetime discounts
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Order Now Order in Chat

Ensure originality, uphold integrity, and achieve excellence. Get FREE Turnitin AI Reports with every order.