Question
I have a code that needs to be adjusted to get the outcome needed. question is the following: Assume that a list of movies produced
I have a code that needs to be adjusted to get the outcome needed.
question is the following: Assume that a list of movies produced in different years are listed in a text file.Assume that the name of the text file is movies.txt.For example, here is some set of movies. Please feel to add, change, edit the test data.
Fargo, 1970
Wanda, 1970A
irport, 1970
Red Sun, 1971
Solaris, 1971
Fargo, 1990
Airport, 1981
You will write a program
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
To identify whether the given collection has any movies with the same name
To report out any movies with the duplicate names.
For example, here is a sample output of the program if there are no duplicates
File movies.txt is processed.
There are no duplicate movies.
For example, here is a sample output of the program if there are duplicates
File movies.txt is processed.
Here are the movies with the duplicate names.
Fargo, 1970
Fargo, 1990
Airport, 1970
Airport, 1981
the code I have so far is this:
MovieCollection class:
import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner;
public class MovieCollection { ArrayList
}
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started