Question: For the following implementations in Main: 1 . 1 . Implement a HashMap call movieYearMap whose key is the movie Year, an Integer, and whose

For the following implementations in Main:
1.1. Implement a HashMap callmovieYearMapwhose key is the movie Year, an Integer, and whose Value is a List of all Movies in that year(5 points)
2.2. Loop over all of the Movies in the data file. Add each movie tomovieYearMap(20 points)
import java.io.*;
import java.util.Scanner; // Import the Scanner class to read text
class Main {
public static void main(String[] args){
String data;
try {
File myObj = new File("IMDB-Movie-Data.csv");
Scanner myReader = new Scanner(myObj);
data = myReader.nextLine();// Read and ingnore header line in file
// while (myReader.hasNextLine()){
data = myReader.nextLine();
Movie temp_movie = new Movie();
temp_movie = parseMovie(data);
//If line of data created a valid Movie object
if(temp_movie.getTitle()!= "Invalid_data"){
//Print Movie Obkect details
temp_movie.printMovieDetails();
}
//}
} catch (FileNotFoundException e){
System.out.println("An error occurred.");
e.printStackTrace();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!