Write java code that parses (reads) the Netflix data file and allows the user to
ID: 3566892 • Letter: W
Question
Write java code that parses (reads) the Netflix data file and allows the user to apply and
remove filters to customize the results. 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 > ____
? rating < ____
Class Design
An abstract Media class, with concrete Movie and Series subclasses
NetflixFileReader 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.
A Filter class that represents a single filter. 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.
The file to be read is shown below
Explanation / Answer
public class Filter {
private String filterName;
private String filterRelation;
private String filterValue;
public Filter(String filterName, String filterRelation, String filterValue) {
super();
this.filterName = filterName;
this.filterRelation = filterRelation;
this.filterValue = filterValue;
}
public String getFilterName() {
return filterName;
}
public void setFilterName(String filterName) {
this.filterName = filterName;
}
public String getFilterValue() {
return filterValue;
}
public void setFilterValue(String filterValue) {
this.filterValue = filterValue;
}
public String getFilterRelation() {
return filterRelation;
}
public void setFilterRelation(String filterRelation) {
this.filterRelation = filterRelation;
}
}
public class NetflixMainApp {
private static ArrayList<Media> masterList,currentList=new ArrayList<Media>();
static Scanner scan=new Scanner(System.in);
private static ArrayList<Filter> filterList=new ArrayList<Filter>();
public static void main(String[] args)
{
masterList=NetflixFileReader.readNetflixData("NetflixUSA.txt");
showMainMenu();
}
public static void showMainMenu() {
System.out.println("***Menu***");
System.out.println("1.Apply Filter 2.Remove Filter 3.Exit");
int choice=Integer.parseInt(scan.nextLine());
switch(choice)
{
case 1:
applyFilter("Add");
showMainMenu();
case 2:
applyFilter("Remove");
showMainMenu();
case 3:
System.exit(1);
default :
System.out.println("Wrong choice");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.