Question: 1a. Create a NetBeans project using the naming convention Lab102-LastFM Create a class named Scores that has the following properties: an instance variable list an
1a. Create a NetBeans project using the naming convention Lab102-LastFM
Create a class named Scores that has the following properties:
an instance variable list an array of int type: This structure will hold the numbers.
an instance variable count of int type: This will provide the count of numbers currently stored in the Scores object. This count will increment when a new number is added to the list and decrement when a number is removed from the list
Provide a default constructor that will initialize the instance variable list to a new array of length 50.
Provide an overloaded constructor that will take an int value as parameter and initialize list to a new array of that length.
Implement the following methods:
Size()
isEmpty()
clear()
getFrequencyof(int num)
contains(int num)
add(int num)
remove(int num)
remove()
get(int i)
toString()
equals(Object o)
1b.
Finally design a java class Client with the main( ) method that does the following:
Create an Object of Type Scores using the overloaded constructor and pass the value 100.
Use a for loop to populate the list in Scores object with 100 random numbers between
-100 and +100 inclusive. (Use the Random class from java.util package to generate pseudorandom numbers).
Call toString( ) to print the contents of the Scores object.
Call the add( ) method to add the number 86 to the Scores object.
Print the current size of the list in the Scores object.
Call the remove( ) method to randomly remove a number from the Scores object
Get the number at the 75th index position
Print the frequency that the number returned by the previous step occurs in the Scores object.
Call the appropriate overloaded remove method to remove the first occurrence of number at the 75th index position from the Scores object.
Print the frequency that this number now occurs in the Scores object
Print the frequency of the number 86
Check whether the array in Scores object contains the number 86.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
