Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How do I do this question? This question involves the creation and use of a spinner to generate random numbers in a game. A GameSpinner
How do I do this question?
This question involves the creation and use of a spinner to generate random numbers in a game. A GameSpinner object 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 average spin of a spinner object. This is initially 0 until a spinner is spun. Reporting the largest (most sectors) GameSpinner object that has been created. 4 The following table contains a sample code execution sequence and the corresponding results. Method Call Value Explanation Returned (blank if no value) GameSpinner gl = Creates a new spinner with 4 sectors new GameSpinner (4); gi.avgSpin(); Returns the average spin of the current spinner. The average spin for the current spinner is initially o because no spins have occurred. GameSpinner.biggest(); Returns the largest GameSpinner object that has been created. The largest created so far is a GameSpinner with 4 sectors. gi.spin(); Returns a random integer between 1 and 4, inclusive. In this case, 4 is returned. g1.spin(); 3 Returns a random integer between 1 and 4, inclusive. In this case, 3 is returned. gi.avgSpin(); 3.5 The average spin is 3.5 because 2 spins of 4 and 3 have occurred so far. (4+3)/2 = 3.5 gi.spin(); 2 Returns a random integer between 1 and 4, inclusive. In this case, 2 is returned. gi.avgSpin(); 3.0 The average is (4+3+2)/3 = 3 GameSpinner g2 = Creates a new spinner with 5 sectors new GameSpinner (5); g2.avgSpin(); The average spin for the current spinner is initially o because no spins have occurred. GameSpinner.biggest(); 5 The largest Game Spinner object created now is one with 5 sectors. Write the complete GameSpinner class. Your implementation must meet all specifications and conform to the exampleStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started