Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE ANSWER IM DESPSERATE!! Code using Java NetBeans. boolean contains ( int num ) method that Tests whether Scores class contains the number num. Returns
PLEASE ANSWER IM DESPSERATE!! Code using Java NetBeans. boolean contains int num method that Tests whether Scores class
contains the number num. Returns true when the num is contained in Scores class.
void add int num method that always adds to the "next available" slot in
the array.
This method should add a new number to the end of the list ie the next open
slot in list
Restrictions:
Unless directed otherwise, you cannot use any Java class libraries in this
assignment. In particular, you cannot use the Arraylist class nor can you use
any methods from the Arrays class.
If needed:
you may create and use one or more instances of an array and access the
length instance variable for each array.
you may NOT access any other methods from the Arrays class.
you may use the Java Random class.
you may NOT use the Math.Random class
Of course, you may use the System.print, println, and printf methods.
In this project you will be doing the following:
Create a NetBeans project using the naming convention LabLastFM
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 Scores class. 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
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:
int size method that returns a count of numbers in Scores class
boolean isEmpty method that checks if Scores class is empty, returns true
when empty
void clear method that removes all the numbers from Scores class
int getFrequencyof int num method that returns a count the number
of times the number num exists in Scores class
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
Use a for loop to populate the list in Scores object with random numbers between
and 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 to Scores object.
Print the current size of the list in the Scores object.
Call the remove method to randomly remove a number from Scores class
Get the number at the index position
Print the frequency of the number returned by the previous step occurs in Scores class
Call the appropriate overloaded remove method to remove the first occurrence of
number at the index position from Scores class
Print the frequency that this number now occurs in Scores class
Check whether the array in Scores object contains the number
Use JavaDoc commenting styles in the Scores class and the Client Review Section in
the textbook Make sure to provide a block comment at the top that provides description of
each class and a JavaDoc comment for each method.
Use in line commenting as needed.
Things to turn in:
Open a Microsoft Word document using the naming convention Lab
LastFM.docx
Copy and Paste the source code of the client class.
make sure to use to select all the source code of the program and
Ctrl to copy
Copy and Paste the source code of the Scores class.
Copy and paste the output of the client program ie the contents of the
consoleterminal
Export the NetBeans project to a zip archive.
Finally, on blackboard, submit your Word document and project zipped file as
two separate files in a single submission.
Step 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