Question: Using the following class and following the instructions below: import java.util.Random; public class NumberGenerator //Instance Variables private int min; // Min number to generate private

Using the following class and following the instructions below:

Using the following class and following the instructions below: import java.util.Random; public

import java.util.Random; public class NumberGenerator //Instance Variables private int min; // Min number to generate private int max; 1/ Max number to generate // Constructors NumberGenerator () min max-0; NumberGenerator (int minNum, int maxNum) min = minNum; max = maxNum; // Getters public int getMin) return min; public int getMax () return max; ) public int getNewRandomNumber () Random r-new Random () if (min 0&& max return r.nextInt 17 No min/max bound, so generate any number else return r.nextInt (max-min+1) +min; /7 Generates numbers in range [min, max] Write a new class (from scratch) called UniqueNumberGenerator. Your new class must do the following (use this check-list to make sure you've accomplished all requirements) Be called UniqueNumberGenerator Inherit from NumberGenerator Provide default constructor Provide overloaded constructor (same params as NumberGenerator..pass params through to super-class constructor) Include a private ArrayList instance variable called numsUsed that can hold integers Override the getNewRandomNumber0 method to return a number that hasn't already been used/generated (HINT: use your numsUsed instance variable to keep track of which numbers have been used) . o Assume that if you keep trying, you will eventually generate an unused number (i.e., you do not need to check if every value in your range [min, max] has already been used) o HINT2: You may be able to re-use the code that is already in the NumberGenerator.getNewRandomNumber0 super class method

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!