Question: A die object represents a die with a given number of sides, all with an equal chance of landing face-up during any roll. The Die

 A die object represents a die with a given number of

A die object represents a die with a given number of sides, all with an equal chance of landing face-up during any roll. The Die class supports the following behaviors:

Language: JAVA

A Die object represents a die with a given number of sides, all with an equal chance of landing face up during any roll. The Die class supports the following behaviors. Creating a new die with a specified number of sides Rolling a die and reporting the result Reporting the length of the current run, the number of consecutive rolls that are the same as the most recent roll The following table contains a sample code execution sequence and the corresponding results. Statements Value Comment Retured (blank if no value returned) Die d-new Creates a new Die with sides Die (6) d.currentRun() 0 Returns the length of the current run. The length is initially since no rolls have occurred d.roll) 3 Returns a random integer between 1 and 6, inclusive. In this case a 3 is returned d. Current Run() 1 The length of the current run is 1 because there has been 1 roll of a 3. d.roll(); 3 Returns a random integer between 1 and 6 Inclusive. In this case a 3 is returned d. currentRun() 2 The length of the current run is 2 because there have been 2 rolls of a 3 in a row. d.roll(); 5 Returns a random integer between 1 and 6 Inclusive. In this case a 5 is returned d.currentRun() 1 The length of the current run is 1 because there has been 1 roll of a s. d.roll() 3 Returns a random integer between 1 and 6, inclusive. In this case a 3 is returned d. current Run(); 1 The length of the current run is 1 because there has been 1 roll of a 1. d.ro 1 Returs a random integer between 1 and 6 Inclusive. In this case a 1 is returned d.ro 1 Returns a random integer between 1 and 6 Inclusive. In this case a 1 is returned d.roll() 1 Returns a random Integer between 1 and 6, inclusive. In this case a 1 is returned d.currentRun(); 3 The length of the current run is because there have been 3 rolls of a 1. Write the complete Die class. Your implementation must meet all specifications and conform to the example. Fair warning!! Your code should NOT include System.out.printin anywhere. There may be a print call made in a client class that would require your methods to return properly, but this is of no concern for this test

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!