Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This question is in Java. Please help. This question involves the creation and use of a spinner to generate random numbers in a game. A
This question is in Java. Please help.
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. The following table contains a sample code execution sequence and the corresponding results. Method Call Value Explanation Returned (blank if no value) GameSpinner gi Creates a new spinner with 4 sectors new GameSpinner (4); gl. avgSpin(); 0.0 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(); 4. Returns the largest GameSpinner object that has been created. The largest created so far is a GameSpinner with 4 sectors. g1.spin(); 4 Returns a random integer between 1 and 4, inclusive. In this case, 4 is returned. gl.spin(); 3 Returns a random integer between 1 and 4, inclusive. In this case, 3 is returned. gl.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 gl.spin(); 2. Returns a random integer between 1 and 4, inclusive. In this case, 2 is returned. gl.avgSpin(); 3.0 The average is (4+3+2)/3 = 3 GameSpinner g2 Creates a new spinner with 5 sectors new GameSpinner (5); 92.avgSpin(); 0.0 The average spin for the current spinner is initially o because no spins have occurred. GameSpinner.biggest(); 5 The largest GameSpinner object created now is one with 5 sectors. Write the complete GameSpinner class. Your implementation must meet all specifications andStep 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