Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask Java Expert


Home >> Java

problem 1) prepare a Java program to implement a dice game. You will need to create two classes for this assignment:

class Die is used to represent a single die (the singular form of dice). This class should have the following attributes:

• instance variables:

• sides: an int value representing the number of sides your die has (most games use 6-sided dice, but there are plenty of variations)

• value: an int value representing the current roll of the die; would be a number between 1and sides

• a Random object

• instance methods:

• two constructors:

• the default constructor must set the value of sides to 6, initialize the Random object and roll the die to get an initial value for variable value

• another constructor which takes a single argument representing the number of sides you want your die to have, sets sides to this value, and does all the same operations the other constructor does

• one mutator method called roll, which rolls the die (generates a random number between 1 and sides, which is then assigned to value)

• one accessor method called getRoll, which returns value

• a main method for testing that the other methods work

Your second class represents the game; the name of the class would be up to you. This class would also contain a main method, which is the driver for the game. You might want to include other methods, depending on how complicated your game is. You should meet the following requirements:

• Your game should use at least two dice (2 Die objects, in other words)

• Your game should have at least two players: the user and the computer

• You should have a way to keep score and to inform the user of his/her score

• The computer must play to win, if that is possible (if not a pure game of chance)

• The user should be given the option to play again once a game is completed

Java, Programming

  • Category:- Java
  • Reference No.:- M94591

Have any Question? 


Related Questions in Java

Overviewthis assignment is intended to familiarize students

Overview: This assignment is intended to familiarize students with web application design, basic servlet functionality, and application deployment with a focus on servlet HTML generation and page navigation. The goal is ...

Part 1 text readingchapter 3 chapter 4 part 2 textbook

Part 1. Text reading Chapter 3, Chapter 4 Part 2 . Textbook questions Chapter 3. Describe why an application developer might choose to run over TCP rather than UDP. Suppose host A is sending host B a large file over a TC ...

Twitter is a popular social media platform for users to

Twitter is a popular social media platform for users to send out a short message (a "tweet") to other users who are registered as his/her followers. Figure 1 shows a graph. (The topic on graphs will be covered after your ...

The class below has some errors for each error do the

The class below has some errors. For each error do the following: a) Write the erring section of code and explain what the error is. b) Fix the error (i.e. re-write the code correctly). public class ClassWithErrors { pub ...

This assignment is based on the principles of clock

This assignment is based on the principles of clock consistency and associated drifts in a distributed system. You have to create a simulation, running on a single machine, of a simple distributed system involving four p ...

Assignmentupload your completed assignment to the

Assignment Upload your completed assignment to the Assignment 2 link on the course home page for marking and tutor feedback. Be sure to complete the final step-click on the Send for Marking button to notify your tutor. P ...

Chapter 1 - challenge 3 - training workshopsyour company

Chapter 1 - Challenge #3 - Training Workshops Your company likes to present training workshops that help people in the information technology industry improve their skills. Your task is to write and object-oriented appli ...

Code reviewcan some have this done immediatelypublic class

Code Review Can some have this done immediately public class BankAccount { private double balance; public BankAccount() { balance = 0; } public BankAccount(double initialBalance) { balance = initialBalance; } public void ...

Animal characteristicsin todays fast-paced world it is

Animal characteristics In today's fast-paced world, it is important for programmers to think about potential future changes that impact their programs. One way that software developers can address this concern is by desi ...

Java programmingnow that your survey class has been

Java programming Now that your Survey class has been implemented, it is time to implement the SurveyConductor application class. This class uses the Survey class to conduct a survey. First, create pseudocode to develop t ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate