A09

Due Date: Thursday, March 28
File(s) to be submitted: RatedEpisode.java, TopShows.java
Sample Output: SampleOutput.html
Starter Files:


SUBMIT   /   Check

Working with QuickSort (Recursive sorting methods)

Summary

Your job this week is to write a program (TopShows) that finds and extracts the top-rated episodes from a list of episodes with ratings. As part of that task, you need to create a couple of Comparators in the class RatedEpisode.

I have provided you with a list of Northern Exposure episodes along with their IMDb ratings.

Your program must use methods from the provided class Quick. It may not use any sorting methods not found in that class.

Your program must use the RatedEposide class to hold the information about the episodes. This class has a method called parseEpisode that can be used to change a line from a text file (such as NorthernExposureEpisodes.txt) into RatedEpisode objects.

Details

Your program must execute the following steps, with a pause after each:

  1. Print a program introduction including the program title, a short description and your name and A-number. (You may use the matching values from the sample output.)
  2. Ask for the file name and for the number of top episodes desired. After loading the file the program must report how many episodes were loaded. When asking for the number of top episodes, the program must reject numbers outside the range of 1 to the number of episodes loaded. The top episodes must be placed in a separate list after they've been found.
  3. Check the remaining episodes for any episodes with a ranking as high as the lowest-ranked episode in the top episdoes. It must report how many episodes were added (or that none were added).
  4. Sort the top episodes into the order they aired (by season number and episode number), then presents that sorted list of top episodes. It states how many episodes there are (which may be more than the user asked for) and then lists them all, one per line (with a leading space-hyphen-space).

I have provided a file named NorthernExposureEpisodes.txt. If you are using NetBeans this file needs to be in your project folder (A09/, or whatever you name your project), not in its src/ folder or any other subfolder).

When you use that file and ask for the top 20 episodes it will find that the lowest-rated episode of the top 20 has a rating of 8.4. There are two more episodes (outside the top 20) that have a rating of 8.4, so it adds them to the top-20 list to make a top-22 list. That is the list it prints out at the end. (See the sample output.)

I have provided you with a class called Quick that has multiple quicksort-based methods defined in it. It has two versions of each method -- one with a Comparator and one without. The methods you might be interested in are:

Note that, for the versions with a Comparator, "smallest" and "largest" are defined in terms of that Comparator. For versions without, the "natural order" is used.

I have provided you with a class called RatedEpisode which tracks the season number, episode number (within season), title, and IMDb rating for an episode. You will be interested in the method parseEpisode which takes a String with episode information and parses it into a RatedEpisode. You can read the text file line by line and parse each line into a RatedEpisode to add to your List of RatedEpisodes.

For efficiency reasons, use an ArrayList as the object type.

The RatedEpisode class has no Comparators defined. You will need to add at least two:

You may add other Comparators as desired, or as required for your program to work.


SUBMIT   /   Check