Answered step by step
Verified Expert Solution
Link Copied!

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 1,2,3,4,
5, or -1
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 0.0
Any invalid rating, ratings of -1, will be ignored during this calculation (eg. A Song with ratings 1,5,-1,-1 has
an average rating of 3.0)
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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions