Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

I have been given a data file on eCourseware that lists about 10,500 items from a totally hypothetical media streaming service. Each line is formatted

I have been given a data file on eCourseware that lists about 10,500 items from a totally hypothetical media streaming service. Each line is formatted like this:

Title (Year) | Average User Rating, Length

The length is expressed in a format like 53m or 1hr 47m for a movie, or in a number of episodes/seasons/volumes/etc. for a series. Note that for this assignment, we will assume that a movie is anything thats not a series. This includes things like documentaries, comedy specials, etc.

In case youre curious, the file lists all of Netflixs USA offerings as of Oct. 15, 2012. If youre wondering why this isnt more recent, its surprisingly difficult to find a plain text file of Netflixs current offerings. The older data is a bit more interesting anyway, since Netflix recently abolished their star rating system in favor of a simpler thumbs-up, thumbsdown system.

The Assignment

In this project youll be writing some software that parses (reads) the data file and allows the user to apply and remove filters to customize the results. That should make it easier to pick from the huge selection of options available! For example, the user may want to see a list of all the TV series after 1999 that are rated higher than 4.0 stars. This would be expressed using the following three filters:

1. genre = series 2. year > 1999 3. rating > 4.0

The user should be able to add as many filters as s/he desires, and the software should allow the user to display a list of the items from the data file that match all the filters. The user should also be able to remove filters at will. Every time a filter is added or removed, the software should indicate how many items from the data file match the filter list.

At minimum, your software must support the following filter formats:

genre = movie genre = series title = ____ (exact title match) year > ____ year ____ rating

However, feel free to implement other filters as well! Some suggestions:

title contains ____ (partial title match) title > ____ (alphabetical comparison) title

Class Design

Your project must include the following classes:

An abstract Media class, with concrete Movie and Series subclasses. These classes should be designed to hold all the relevant information about an item that can be obtained from the data file. A DataFileReader class that handles reading the provided data file. For each line of the file, a new Media object (either Movie or Series) should be created and added to a list of Media objects. This class should include a method that returns the finished list. A Filter class that represents a single filter. (You might be tempted to store the filters as plain strings, but making a separate class will allow you to more cleanly access the separate parts of each filter. Note that all the filters are in this format: field relation target) Every time the user adds a filter, a new Filter object should be created and placed in a list. Removing a filter should remove it from this list. A client program with a main method to run.

Heres an outline of what the client program needs to do:

Read the data file and create a new Media object for each line in the file. Store these objects in a list (call this masterList). Allow the user to specify any number of filters. These filters will be stored in a separate list (call this filterList). Each time the user adds a new filter or removes an existing filter, your code needs to search the masterList to find only the objects that match all the filters in the filterList. Copy those objects into another list (call this currentList). You can simply list the items in the currentList to see which items match all filters.

Other Requirements

Implement error checking on all user inputs, including exception handling where appropriate. Your software should never crash due to user input! Examples of error checking that should be implemented: o Ensuring the user cannot enter an invalid filter o Ensuring the user cannot remove a filter that doesnt exist o Ensuring the user cannot enter an invalid entry after any menu Use Javas built-in classes (either java.util.ArrayList or java.util.LinkedList) to store the lists of Media objects and the list of Filter objects. How you enter filters in the client program is up to you. The version Ill demonstrate in class allows you to type in the filters directly, but if you prefer to write a menu-based system thats OK too.

Hints

The file reading part is not super difficult, but it is not trivial. Get started on this part early, since you need it for the rest of the project! You should be able to complete the vast majority of this part without any knowledge of lists. In some IDEs (including BlueJ), Ive noticed that Scanner sometimes stops prematurely when trying to read large text files. A workaround is to use a FileReader object in the Scanner constructor instead of a File object. So instead of

Scanner longLiveSloths = new Scanner(new File(yourFileName));

do this:

Scanner longLiveSloths = new Scanner(new FileReader(yourFileName));

Refer to the String class in the Java API for some helpful methods. I used charAt, equals, split, and substring very often in my solution. Strings cannot be cast to primitive types. However, you can use the static methods Double.parseDouble and Integer.parseInt can be used to convert strings into double and int, respectively. These methods throw a NumberFormatException if you try passing an argument that cant be read as that type.

image text in transcribed

This is what a portion of the list of what was on Netflix on October 15th 2012. I need a code that follows all the instructions given above by 5:30 PM on Monday November 13th.

!Women Art Revolution (201 3 stars, 1hr 22m #1 Cheerleader Camp (2010) | 3 stars, 1hr 35m $5 a Day (288)3.4 stars, 1hr 37m 'night, Mother (1986) 3.7 stars, 1hr 36m Til Death (2006-209) 3.7 stars, 4 Seasons SSuicide Room (2011)3.4 stars, 1hr 51m And God Spoke (1993)2.8 stars, 1hr 22m Com for Murder (2002) 2.8 stars, 1hr 37m 1 a Minute (2010) 2.4 stars, 1hr 29m 1 Love (2803)3.5 stars, 1hr 33m 18:30 P.M. Summer (1966) 2.7 stars, 1hr 24m 18 Dead Men (2038)2.5 stars, 1hr 38m 18 Items or Less (2086-20e92.9 stars, 3 Seasons 10 mph (2807)3.2 stars, 1hr 33m 0 Questions for the Dalai Lama (2006)3.8 stars, 1hr 26m e to Midnight (1983)| 3.5 stars, 1hr 41m 1e Yards: Fantasy Football (2008)2.5 stars, 1hr 30m 10.5 (2004)3.7 stars, 2 Episodes 180 Million BC (2808) 2.8 stars, 1hr 25m 100 Tears (2007) 2.5 stars, 1hr 31m 180 Voices: A Journey Home (212.7 stars, 1hr 32m 180 Women (2802) 3.2 stars, 1hr 34m 1800 Ways to Die (2088-2003.6 stars, 2 Seasons 11/11/11 (2011) |2.7 stars, lhr 27m 11/4/08 (2010)2.4 stars, 1hr 10m 11-11-11: The Prophecy (2011) 3 stars, 1hr 22m 12 Dates of Christmas (2011) | 3.9 stars, 1hr 27m 13 Assassins (2011) |4 stars, 2hr 13 Moons (2082) |2.8 stars, 1hr 34m 1313: Actor Slash Model (2811) 1.7 stars, 1hr 12m 1313: Bermuda Triangle (2011) 1.7 stars, 1hr 14m 1313: Bigfoot Island (2011)1.8 stars, 1hr 16m 1313: Billy the Kid (2012) | 1.9 stars, 1hr 12m

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_2

Step: 3

blur-text-image_3

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students explore these related Databases questions

Question

4. Show the trainees how to do it again.

Answered: 3 weeks ago