Ask Question, Ask an Expert


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

Assignmentbullusing html css and javascript design a

Assignment • Using HTML, CSS and JavaScript. Design a webpage with the following: • The design of all Web pages in the site must include: o a header at the top of the page, o a horizontal navigation bar below the header, ...

Consider the following tilde table that could be

Consider the following "tilde table" that could be represented by the file cars.txt for persistence MAKE~MODEL~TYPE~PRICE Toyota~Camry~Sedan~18000 Toyota~Tacoma~Truck~19000 Ford~Mustang~Sport~21000 Chevrolet~Corvette~Spo ...

Program 1objectivethis program assignment is provided to

Program 1 Objective: This program assignment is provided to let the students know how to handle threads and enhance system availability on a multiprocessor or multicore environment. A single process is supposed to create ...

Module assignment introduction to programming using

Module Assignment: Introduction to Programming Using Java This assignment is to provide practice using arrays and strings along with other Java programming techniques discussed so far in the course. For this assignment, ...

Assignment introduction to programming using java1 write a

Assignment: Introduction to Programming Using Java 1. Write a program that uses one of the Map classes to implement a contact list. Contact information should include first name, last name, a phone number and an email ad ...

The requirement is to design a system using jsp in

The requirement is to design a system using jsp in netbeans. You need to add other functions such as search by text, advance search, quantity update by admin, quantity check at the checkout, login and registering page, a ...

Assignmentobjectivethis project focuses on demonstrating

Assignment Objective This project focuses on demonstrating your understanding of Java Collections. Before attempting this project, be sure you have completed all of the reading assignments listed in the syllabus to date, ...

Java programthis assignment will count as both homework and

Java Program This assignment will count as both homework and lab. Develop a program that will allow the user to display the starting line and the bench for a basketball team. The user will also have the option of swappin ...

Create your own simple java application to generate x

Create your own simple Java application to generate X random Integer values between 0 and Y. Use command line arguments for entry of X and Y. Demonstrate your code compiles and runs without issue using screen captures as ...

Jva programmingmodify the given java application attached

JAVA PROGRAMMING Modify the given Java application (attached) using NetBeans IDE to meet these additional and changed business requirements: • The application will now compare the total annual compensation of at least tw ...

  • 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

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro