Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with my Java homework! Can someone help me? _________________________________________________________________________________________________ A data file (NetflixUSA_Oct15_cleaned.txt) is included on eLearn that lists about 10,500

I need some help with my Java homework! Can someone help me?

_________________________________________________________________________________________________

A data file (NetflixUSA_Oct15_cleaned.txt) is included on eLearn 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, thumbs-down 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:

genre = series

year > 1999

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 > ____

rating < ____

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

title contains ____ (partial title match)

title > ____ (alphabetical comparison)

title < ____ (alphabetical comparison)

Anything involving the length (for example, length < 2hr)

_________________________________________________________________________________________________

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 Mediaobject (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 thisfilterList).

Each time the user adds a new filter or removes an existing filter, your code needs to search the masterListto 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:

Ensuring the user cannot enter an invalid filter

Ensuring the user cannot remove a filter that doesnt exist

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 Mediaobjects and the list of Filter objects.

Create a menu-based system that will allow user to select and type in the filter directly.

_________________________________________________________________________________________________

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, 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, andsubstring very often in my solution.

Strings cannot be cast to primitive types. However, you can use the static methods Double.parseDoubleand 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.

_________________________________________________________________________________________________

Here's a small excerpt of the NetflixUSA_Oct15_cleaned.txt file (it's ~10,500 lines long so I excluded most of it for brevity's sake):

!Women Art Revolution (2010) | 3 stars, 1hr 22m #1 Cheerleader Camp (2010) | 3 stars, 1hr 35m $5 a Day (2008) | 3.4 stars, 1hr 37m 'night, Mother (1986) | 3.7 stars, 1hr 36m 'Til Death (2006-2009) | 3.7 stars, 4 Seasons @Suicide 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 (2003) | 3.5 stars, 1hr 33m 10:30 P.M. Summer (1966) | 2.7 stars, 1hr 24m 10 Dead Men (2008) | 2.5 stars, 1hr 30m 10 Items or Less (2006-2009) | 2.9 stars, 3 Seasons 10 mph (2007) | 3.2 stars, 1hr 33m 10 Questions for the Dalai Lama (2006) | 3.8 stars, 1hr 26m 10 to Midnight (1983) | 3.5 stars, 1hr 41m 10 Yards: Fantasy Football (2008) | 2.5 stars, 1hr 30m 10.5 (2004) | 3.7 stars, 2 Episodes 100 Million BC (2008) | 2.8 stars, 1hr 25m 100 Tears (2007) | 2.5 stars, 1hr 31m 100 Voices: A Journey Home (2010) | 2.7 stars, 1hr 32m 100 Women (2002) | 3.2 stars, 1hr 34m 1000 Ways to Die (2008-2009) | 3.6 stars, 2 Seasons 11/11/11 (2011) | 2.7 stars, 1hr 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 5m 13 Moons (2002) | 2.8 stars, 1hr 34m 1313: Actor Slash Model (2011) | 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 1313: Cougar Cult (2012) | 1.7 stars, 1hr 13m 1313: Frankenqueen (2012) | 1.5 stars, 1hr 16m 1313: Hercules Unbound (2012) | 1.5 stars, 1hr 12m 1313: Night of the Widow (2012) | 1.6 stars, 1hr 16m 1313: UFO Invasion (2011) | 1.6 stars, 1hr 24m 1313: Wicked Stepbrother (2011) | 1.9 stars, 1hr 15m 13B (2009) | 2.9 stars, 2hr 8m 13Teen (2005) | 2.8 stars, 1hr 22m 16 Fathoms Deep (1948) | 2.5 stars, 1hr 18m 16 to Life (2009) | 3.4 stars, 1hr 29m 16-Love (2012) | 3.7 stars, 1hr 28m 18 to Life (2010-2011) | 3.7 stars, 2 Seasons 180 South (2010) | 4.1 stars, 1hr 26m 1911 (2011) | 3.4 stars, 1hr 39m 1981 (2009) | 2.8 stars, 1hr 42m 1984 (1984) | 3.5 stars, 1hr 50m 2 Become 1 (2006) | 2.9 stars, 1hr 37m 2 Days (2003) | 3 stars, 1hr 31m 2 Days in Paris (2007) | 2.9 stars, 1hr 40m 2 Months, $2 Million (2009) | 3.5 stars, 1 Season 2-Headed Shark Attack (2012) | 2.8 stars, 1hr 27m 20 Years After (2008) | 2.9 stars, 1hr 35m 200 Motels (1971) | 3.1 stars, 1hr 39m 200 mph (2011) | 3 stars, 1hr 32m 2000 A.D. (2000) | 2.9 stars, 1hr 44m 2010: Moby Dic (2010) | 2.5 stars, 1hr 27m 2012: An Awakening (2009) | 3.1 stars, 1hr 8m 2012: Ice Age (2011) | 2.8 stars, 1hr 31m 2012: Mayan Prophecy and the Shift of the Ages (2009) | 3 stars, 1hr 16m 2012: Science or Superstition (2008) | 3.2 stars, 1hr 18m 2012: Time for Change (2010) | 3.7 stars, 1hr 25m 2012: Zombie Apocalypse (2011) | 2.9 stars, 1hr 27m 21 Grams (2003) | 3.5 stars, 2hr 4m 21 Hours at Munich (1976) | 3.3 stars, 1hr 41m 21 Up (1977) | 3.9 stars, 1hr 39m 21 Up South Africa: Mandela's Children (2006) | 3.5 stars, 1hr 14m 24 (2001-2010) | 3.9 stars, 8 Seasons 2501 Migrants: A Journey (2009) | 3.1 stars, 54m 26 Years: The Dewey Bozella Story (2012) | 3.7 stars, 49m 28 Up (1985) | 3.9 stars, 2hr 53m 2nd Take (2011) | , 1hr 42m 3 (2010) | 3 stars, 1hr 59m 3:15 (1986) | 2.9 stars, 1hr 25m 3 Magic Words (2010) | 3.3 stars, 1hr 10m 3 Musketeers (2011) | 2.9 stars, 1hr 27m 3 Steps to Heaven (1995) | 2.2 stars, 1hr 31m 3 Women (1977) | 3.3 stars, 2hr 3m 3-Day Weekend (2008) | 2.9 stars, 1hr 23m 30,000 Leagues Under the Sea (2007) | 2.6 stars, 1hr 25m 30 Days (2005-2008) | 3.7 stars, 3 Seasons 30 for 30: Catching Hell (2011) | 4 stars, 1hr 48m 30 for 30: Charismatic (2011) | 3 stars, 51m 30 for 30: Fernando Nation (2010) | 3.8 stars, 53m 30 for 30: Four Days in October (2010) | 4.1 stars, 52m 30 for 30: Guru of Go (2010) | 3.8 stars, 53m 30 for 30: Into the Wind (2010) | 3.8 stars, 56m 30 for 30: Jordan Rides the Bus (2010) | 3.8 stars, 54m 30 for 30: June 17th, 1994 (2010) | 3.6 stars, 52m 30 for 30: Kings Ransom (2009) | 3.6 stars, 52m 30 for 30: Little Big Men (2010) | 3.4 stars, 52m 30 for 30: Marion Jones: Press Pause (2010) | 3.5 stars, 53m 30 for 30: Muhammad and Larry (2009) | 3.6 stars, 53m 30 for 30: No Crossover: The Trial of Allen Iverson (2010) | 3.7 stars, 1hr 22m 30 for 30: Once Brothers (2010) | 4.1 stars, 1hr 22m 30 for 30: Pony Excess (2010) | 4 stars, 1hr 46m 30 for 30: Rene (2011) | 2.9 stars, 1hr 18m 30 for 30: Roll Tide / War Eagle (2011) | 3.9 stars, 53m 30 for 30: Run Ricky Run (2010) | 3.9 stars, 53m 30 for 30: Silly Little Game (2010) | 3.4 stars, 52m 30 for 30: Small Potatoes: Who Killed the USFL? (2009) | 3.7 stars, 53m 30 for 30: The 16th Man (2010) | 3.8 stars, 53m 30 for 30: The Band That Wouldn't Die (2009) | 3.4 stars, 54m 30 for 30: The Best That Never Was (2010) | 4 stars, 1hr 41m 30 for 30: The Birth of Big Air (2010) | 4 stars, 54m 30 for 30: The Dotted Line (2011) | 3.6 stars, 56m 30 for 30: The House of Steinbrenner (2010) | 3.4 stars, 53m 30 for 30: The Real Rocky (2011) | 3.8 stars, 57m 30 for 30: The Two Escobars (2010) | 4.2 stars, 1hr 45m 30 for 30: The U (2010) | 4.1 stars, 1hr 43m 30 for 30: Tim Richmond: To The Limit (2010) | 3.6 stars, 53m 30 for 30: Unguarded (2011) | 4.2 stars, 1hr 20m 30 for 30: Unmatched (2010) | 3.2 stars, 53m 30 for 30: Winning Time: Reggie Miller vs. The New York Knicks (2010) | 4.2 stars, 1hr 10m 30 for 30: Without Bias (2009) | 3.9 stars, 52m

...

Foreign Parts (2010) | 2.1 stars, 1hr 20m Foreign Student (1994) | 2.7 stars, 1hr 35m Foreigner: Alive & Rockin' (2007) | 3.5 stars, 1hr 8m Forensics: You Decide (2009) | 3.9 stars, 1 Season Forest of Bandi: Fireflies (2011) | , 30m Forever Female (1954) | 3.4 stars, 1hr 33m Forever Lulu (2000) | 2.8 stars, 1hr 42m Forever Plaid: The Movie (2008) | 3.3 stars, 1hr 25m Forever Strong (2008) | 4.2 stars, 1hr 49m Forever Young (1992) | 3.5 stars, 1hr 41m Forget Me Not (2009) | 3.4 stars, 1hr 43m Forgiven (2011) | 3.4 stars, 1hr 35m Forgiving Dr. Mengele (2006) | 3.6 stars, 1hr 19m Forks Over Knives (2011) | 4.2 stars, 1hr 36m Forks Over Knives Presents: The Engine 2 Kitchen Rescue (2011) | 3.8 stars, 52m Fort Dodge Stampede (1951) | 3.3 stars, 59m Fort Massacre (1958) | 3.4 stars, 1hr 20m Fort Utah (1967) | 3.4 stars, 1hr 23m Four Days (1999) | 2.8 stars, 1hr 28m Four Days in November (1964) | 3.7 stars, 2hr 2m Four Faces West (1948) | 3.5 stars, 1hr 30m Four Lions (2010) | 3.4 stars, 1hr 41m Four Rooms (1995) | 3.6 stars, 1hr 37m Foxfire Light (1982) | 3.5 stars, 1hr 37m Foxy Brown (1974) | 3.4 stars, 1hr 31m Frulein Doktor (1969) | 2.9 stars, 1hr 41m Fraggle Rock (1983-1986) | 3.7 stars, 5 Seasons Fragile (2005) | 3.4 stars, 1hr 41m Fragments (2008) | 3 stars, 1hr 35m Frame 313: The JFK Assassination Theories (2008) | 3.7 stars, 1hr 54m Frances: Bedtime for Frances (2009) | 3.2 stars, 46m Frank & Jesse (1995) | 3.6 stars, 1hr 46m Frank Caliendo: All Over the Place (2007) | 3.5 stars, 1hr 9m Frank Lloyd Wright (1998) | 3.8 stars, 2hr 36m Frank Zappa: Apostrophe /Over-Nite Sensation (2007) | 3.6 stars, 49m Frankensteer (2006) | 3.7 stars, 44m Frankenstein (2004) | 3.1 stars, 1hr 27m Frankenstein (2004) | 3.3 stars, 2 Episodes Franny's Feet (2003) | 3.5 stars, 18 Episodes Frasier (1993-2003) | 3.8 stars, 11 Seasons Fraternity House (2008) | 2.4 stars, 1hr 21m Frauds (1993) | 2.1 stars, 1hr 33m Fraulein (2006) | 3.2 stars, 1hr 15m Freak Encounters (2010) | 3.3 stars, 1 Season Freakonomics (2010) | 3.7 stars, 1hr 33m Freaks and Geeks (1999) | 4.6 stars, 18 Episodes Freakshow (2007) | 2.7 stars, 1hr 25m Freaky Eaters (2010) | , 1 Season Freaky Faron (2006) | 2.9 stars, 1hr 16m Fred: The Movie (2010) | 3 stars, 1hr 22m Fred 2: Night of the Living Fred (2011) | 3.4 stars, 1hr 22m Fred 3: Camp Fred (2012) | 3.4 stars, 1hr 20m Freddy Frogface (2011) | 3.3 stars, 1hr 24m Free Money (1998) | 3 stars, 1hr 33m Free Radicals (2003) | 2.5 stars, 1hr 54m Free Willy (1993) | 3.3 stars, 1hr 51m Free Willy 2: The Adventure Home (1995) | 3.5 stars, 1hr 37m Free Zone (2005) | 2.6 stars, 1hr 30m Freedom Fries: And Other Stupidity We'll Have to Explain to Our Grandchildren (2005) | 3.3 stars, 51m Freedom Writers (2007) | 4 stars, 2hr 2m

...

Young Buffalo Bill (1940) | 3.2 stars, 53m Young Cesar (2007) | 3.5 stars, 1hr 18m Young Fury (1965) | 3.1 stars, 1hr 19m Young Goethe in Love (2010) | 3.6 stars, 1hr 44m Young Hercules (1997) | 3.2 stars, 1hr 32m Youngblood (1978) | 3.6 stars, 1hr 26m Yours, Mine and Ours (2005) | 3.5 stars, 1hr 28m ZA: Zombies Anonymous (2005) | 2.6 stars, 1hr 48m Zach Galifianakis: Live at the Purple Onion (2006) | 3.7 stars, 1hr 1m Zack and Reba (1998) | 2.7 stars, 1hr 31m Zeitgeist: The Movie (2007) | 4.1 stars, 1hr 56m Zeke's Pad (2008) | , 1 Season Zen of Sword (1992) | 3 stars, 1hr 28m Zenith (2010) | 2.9 stars, 1hr 32m Zero Bridge (2008) | , 1hr 37m Zero Day (2003) | 3.5 stars, 1hr 31m Zero Kelvin (1995) | 3.1 stars, 1hr 54m Zero to Sixty (1978) | 2.7 stars, 1hr 41m Zodiac: The Race Begins (2006) | 2.8 stars, 1hr 24m Zombie Farm (2009) | 2.4 stars, 1hr 29m Zombie Girl: The Movie (2009) | 3 stars, 1hr 31m Zombie Nation (2004) | 2 stars, 1hr 21m Zombie Town (2007) | 2.6 stars, 1hr 27m Zombie Women of Satan (2009) | 2.2 stars, 1hr 24m Zombies of Mass Destruction (2009) | 2.8 stars, 1hr 29m Zombies Zombies Zombies (2008) | 2.5 stars, 1hr 22m Zombiethon (1986) | 2.6 stars, 1hr 13m Zonad (2009) | 2.4 stars, 1hr 15m Zone Troopers (1985) | 3 stars, 1hr 25m Zoo Baby (1960) | 2.2 stars, 59m Zu Warriors (2001) | 3.2 stars, 1hr 20m Zulu (1964) | 3.8 stars, 2hr 18m Zulu Dawn (1979) | 3.5 stars, 1hr 57m ZZ Top: Live from Texas (2008) | 3.7 stars, 1hr 25m

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions