Computers and Technology
Computers and Technology, 19.05.2020 20:03, Jasten

Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.
This question involves the creation and use of a spinner to generate random numbers in a game. A GameSpinnerobject represents a spinner with a given number of sectors, all equal in size. The GameSpinner class supports the following behaviors.
Creating a new spinner with a specified number of sectors
Spinning a spinner and reporting the result
Reporting the length of the current run, the number of consecutive spins that are the same as the most recent spin
The following table contains a sample code execution sequence and the corresponding results.
Statements ValueReturned(blank ifno valuereturned) Comment
GameSpinner g = new GameSpinner(4); Creates a new spinner with four sectors
g. currentRun(); 0 Returns the length of the current run. The length of the current run is initially 0 because no spins have occurred.
g. spin(); 3 Returns a random integer between 1 and 4, inclusive. In this case, 3 is returned.
g. currentRun(); 1 The length of the current run is 1 because there has been one spin of 3 so far.
g. spin(); 3 Returns a random integer between 1 and 4, inclusive. In this case, 3 is returned.
g. currentRun(); 2 The length of the current run is 2 because there have been two 3s in a row.
g. spin(); 4 Returns a random integer between 1 and 4, inclusive. In this case, 4 is returned.
g. currentRun(); 1 The length of the current run is 1 because the spin of 4is different from the value of the spin in the previous run of two 3s.
g. spin(); 3 Returns a random integer between 1 and 4, inclusive. In this case, 3 is returned.
g. currentRun(); 1 The length of the current run is 1 because the spin of 3is different from the value of the spin in the previous run of one 4.
g. spin(); 1 Returns a random integer between 1 and 4, inclusive. In this case, 1 is returned.
g. spin(); 1 Returns a random integer between 1 and 4, inclusive. In this case, 1 is returned.
g. spin(); 1 Returns a random integer between 1 and 4, inclusive. In this case, 1 is returned.
g. currentRun(); 3 The length of the current run is 3 because there have been three consecutive 1s since the previous run of one 3.
Write the complete GameSpinner class. Your implementation must meet all specifications and conform to the example.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, robert7248
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
image
Computers and Technology, 22.06.2019 17:30, yoyo9661
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, Alexaisokay1
In which of the following ways can using test-taking tips you? a. you can focus on the information that you need to study. b. you will see the answers to the test. c. you will study more. d. you will be less organized.
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, arturocarmena10
The initial tableau of a linear programming problem is given. use the simplex method to solve it. x 1 x 2 x 3 s 1 s 2 z 1 2 4 1 0 0 8 3 4 1 0 1 0 10 minus3 minus12 1 0 0 1 0 the maximum is nothing when x 1equals nothing, x 2equals nothing, x 3equals nothing, s 1equals3, and s 2equals0. (be sure to simplify to lowest terms if necessary.)
Answers: 2
Do you know the correct answer?
Assume that the classes listed in the Java Quick Reference have been imported where appropriate.

Questions in other subjects:

Konu
Mathematics, 05.01.2021 05:00