Question: In Java, Create Movie class, which has private fields for title, director, rating. It has a constructor to initialize these fields and a toString method
In Java, Create Movie class, which has private fields for title, director, rating. It has a constructor to initialize these fields and a toString method for printing movie details. There is also a getRating method to retrieve the movie rating. Create RatingComparator class which implements the Comparator interface for comparing movies based on their ratings. Create DemoMovies Class. Initialize necessary data structures like LinkedList, TreeMap for rating as key and Movie from Movie class as value, TreeSet, and ProtiyQueue. Use a loop to take user input for movie detailsuntil the user enters WWW as the movie title.Inside the loop, for each movie, create a Movie object, add it to various data structures that is title, director and rating based on the constructor.Add the Movie object to the LinkedList. Add the rating and the object to the TreeMap.Add the rating to the TreeSet.Add the Movie object to the PriorityQueue.Display the entered movies. Sort and display Movies by rate by using TreeMap to automatically sort Movies by rate and display them. Remove Movies with Rating less than using removeAll.Use an iterator to go through the list of Movies and remove those with a rating less than use while loop for iterator and if statement for rate less than Create an array list to add the unrented movies and add them to the list created.Use a tree map to store movies with a rating greater than or equal to and display them sorted by Rate.Display the keys and values from the TreeMap.Create a PriorityQueue from the movies stored in the TreeMap and display it based on movie ratings.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
