Question: the following code can read a .txt and find duplicates and display them if found or return a no duplicts if there isn't any, code

the following code can read a .txt and find duplicates and display them if found or return a "no duplicts" if there isn't any, code works I have tested it. I need to add methods to the code that will do the following:

To read this text file

To construct a movie object with two fields (name and year_made) for each line read

To construct a collection of movies (ArrayList, arra[ ], vector )

To ask the user for inputting a movie name as well as the year in which it is made.

To update the file with this movie only if (the movie and the year) does not exist in the file.

For example, here is a sample output of the program if there is no such movie in the file

(Test Case 1)

Enter the movie: Alone

Enter the year: 2020

Movie doesnt exist in the file. Movie is added to the movies.txt

(Test Case 2)

Enter the movie: fargo

Enter the year: 1970

Error! This movie already exist in the movie.

The current code is like this:

MovieCollection class:

import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner;

public class MovieCollection { ArrayList movieList = new ArrayList(); public void printDuplicates(){ int arr[] = new int[2*movieList.size()]; int dup = 0; for(int i=0; i0) { System.out.println(" Here are the movies with the duplicate names:"); for(int i=0;i

}

Movie class:

public class Movie { private String name = "name"; private String year_made = "year_made"; Movie (String name, String year_made){ this.name = name; this.year_made = year_made; } public String getName() { return name; } public String getYear() { return year_made; } public String toString() { return "Name: " + name + "," + "Year: " + year_made; } }

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 Databases Questions!