Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Note: Use the provided ratings.datastructures.LinkedListNode class whenever a linked list is needed. You do not have to modify this class ratings.Song - The following methods
Note: Use the provided ratings.datastructures.LinkedListNode class whenever a linked list is needed. You do not have to
modify this class
ratings.Song The following methods will be added to the Song class:
A method named addRating that takes a reference to an object of type Rating as a parameter The type of the input
is Rating and returns void
This method will be called when a Reviewer rates this Song. All added Ratings will be stored in a Linked List as an
instance variable
This method will append new ratings to the end of the linked list
Note: Since the Rating class checks for valid ratings, any added ratings can only have a rating value of
or
A method named getRatings that takes no parameters and returns a LinkedListNode of Ratings
This method returns the head of a Linked List containing all Ratings that have been added to this Song
The returned Linked List must return the Ratings in the order in which they were added. For example, the first
Rating that was added must be the first value in the list
If no ratings have been added, this method will return null
A method named setRatings that takes a LinkedListNode of Ratings and returns void
This is a setter that replaces the stored linked list of ratings The instance variable with the one provided as a
parameter. This assignment is done by reference ie any prior ratings are replaced by the new list of ratings
A method named averageRating that takes no parameters and returns a double
This method returns the average of all the Ratings of this Song
If the list is empty, the method returns
Any invalid rating, ratings of will be ignored during this calculation eg A Song with ratings has
an average rating of
A method named removeRatingByReviewer that takes a Reviewer as a parameter and returns void
This method will remove a Rating made for this Song by the given Reviewer by id
If the reviewer did not rate this song, this method has no effect
If the linked list contains multiple ratings by the reviewer, the method only removes the first instance from the
list ie the method does not have to handle removing multiple ratings in a single call
In java pls
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