Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need to program in java a game called sequence.. i have created the class call Die which is for the dice. However i need

i need to program in java a game called sequence.. i have created the class call "Die" which is for the dice. However i need another class called Sequence and a Driver Class. Here is info about the game: each player in turn rolls the six dice and scores points for any sequence of consecutive numbers thrown beginning with 1. in the event of two or more of the same number being rolled only one counts. however a throw that contains three 1s cancels out a players score and they must start from zero again. a total score is kept and the first player to reach 100 points wins the game. 1 5 points 1,2 10 points 1,2,3 15 points 1,2,3,4 20 points 1,2,3,4,5 25 poiunts 1,2,3,4,5,6 35 points 1,1,1, cancels player's score the driver class creates an instance of the sequence class. the driver will control how many players there are, read players name and how many games are played and the result of the roll for each turn. display the points for each roll and the score and displays who wins each indiviual game and the tally of each players win./ Die class import java.util.Random; /** * Write a description of class Die here. * * @author (your name) * @version (a version number or a date) */ public class Die { private int numberOfSides; private int face; private Random rng; public Die( ) { numberOfSides = 6; rng = new Random( ); roll( ); } public Die(int inSides) { this.numberOfSides = inSides; rng = new Random( ); roll( ); } public void roll( ) { face = rng.nextInt(numberOfSides) + 1; } public void setNumberOfSides(int inSides) { numberOfSides = inSides; roll( ); } public int getNumberOfSides( ) { return numberOfSides; } public int getFace( ) { return face; } public String toString( ) { return "Number of Sides: " + numberOfSides + " Face value:" + face; } public boolean equals(Die other) { return this.numberOfSides == other.numberOfSides && this.face == other.face; } public int compareTo(Die other) { return this.face - other.face; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

What is an interface? What keyword is used to define one?

Answered: 1 week ago