Implement a Java application for the following:
We want to keep track of a Movie Collection. Each Movie in the collection will contain: Title, Genre, Year (4 digits) and Runtime (double - ex. 2.1 (hrs)). Your program will read movies from a local text file named movies.txt in the current project directory in Eclipse. Each line in the text file contains one Movie with the fields separated by commas.
Read the text file and load the movies in to a Collection. Implement a Comparator for the Movie Class that can sort the movies in ascending order of Title+year. Sort the movies read from the text file (movies.txt) in ascending order of Title+Year and write the sorted collection to a file called sortedmovies.txt in the same directory as movies.txt.
//Java Code
import java.util.Comparator;
import java.util.function.Function;
public class Movie{
private String title;
private String genre;
private int year;
private double runTime;
//Default Constructor
public Movie()
{
title="";
genre="";
year =0;
runTime=0;
}
//Overload Constructor
public Movie(String title, String genre, int year, double runTime) {
this.title = title;
this.genre = genre;
this.year = year;
this.runTime = runTime;
}
//getters and setters
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public double getRunTime() {
return runTime;
}
public void setRunTime(double runTime) {
this.runTime = runTime;
}
public void displayMovie()
{
System.out.println("Movie's Description:\nTitle: "+title+"\n" +
"Genre: "+genre+"\nYear: "+year+"\nRuntime: "+runTime);
}
//=====================================
@Override
public String toString() {
return title+", "+genre+", "+year+", "+runTime;
}
public static Comparator<Movie> MovieComparator = new Comparator<Movie>() {
@Override
public int compare(Movie o1, Movie o2) {
int c1 = o1.title.compareToIgnoreCase(o2.title);
if(c1==0)
{
return o1.year-o2.year;
}
else
return c1;
}
};
}
//==========================================
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
public class MovieTracker {
public static void main(String[] args)
{
ArrayList<Movie>movies = new ArrayList<>();
try {
Scanner scanFile = new Scanner(new File("movies.txt"));
PrintWriter writer= new PrintWriter(new File("sortedmovies.txt")) ;
//read data nad store it into collection
while (scanFile.hasNext())
{
String line = scanFile.nextLine();
String[] tokens = line.split(", ");
movies.add(new Movie(tokens[0],tokens[1], Integer.parseInt(tokens[2]),Double.parseDouble(tokens[3])));
}
//sort the data
Collections.sort(movies, Movie.MovieComparator);
//print data to console and file
for (Movie m:movies
) {
m.displayMovie();
writer.println(m);
}
writer.close();
scanFile.close();
}
catch (FileNotFoundException e)
{
System.err.println("File not Found....");
}
}
}
//Files


//Output

//If you need any help regarding this solution ........ please leave a comment...... thanks
Implement a Java application for the following: We want to keep track of a Movie Collection....
Implement a Java application for the following: 1.) Keep track of a movie collection. 2.) Each movie in the collection will contain: Title, Genre, Year (4 digits) and Runtime (double - ex. 2.1 (hrs)). 3.) Program will read movies from a local text file named movies.txt in the current project directory in Eclipse. 4.) Each line in the text file contains one movie, containing each field, per line.separated by commas. 5.) Read the text file and load the movies into...
LAB 7-Movie List Program Goali Your assignment is to write a C++program to implement the ADT List by creating a list of movies. This assignment will help you practice: multiple file programming, classes, pablic and private methods, dynamie memory, constructors and destructors, arrays and files Implementation the required classes This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of There are two classes to implement: Movie and MovieList. As you can see...
This homework problem has me pulling my hair out. We are working
with text files in Java using NetBeans GUI application. We're
suppose to make a movie list and be able to pull up movies already
in the text file (which I can do) and also be able to add and
delete movies to and from the file (which is what I'm having
trouble with). I've attached the specifications and the movie list
if you need it. Any help would...
Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...
Netflix Database - PROGRAMMED IN JAVA PLEASE :) In this program, you will build a Netflix movie database using the provided file, netflix.csv. The file contains more than two hundred records of movies and TV programs, with each record consisting a title, a rating, a release year, and a user rated score. There are three classes that you will need to implement: Movie, NetflixHandler, and NetflixApp. Class: Movie Movie - title: String - rating: String - year: int - score:...
Need this in C++ Goals: Your task is to implement a binary search tree of linked lists of movies. Tree nodes will contain a letter of the alphabet and a linked list. The linked list will be an alphabetically sorted list of movies which start with that letter. MovieTree() ➔ Constructor: Initialize any member variables of the class to default ~MovieTree() ➔ Destructor: Free all memory that was allocated void printMovieInventory() ➔ Print every movie in the data structure in...
[C++]
Outline:
The movie data is read from a file into an array of structs and
is sorted using the Selection Sort method and the search is done
using the Binary Search algorithm with the year of release as key.
This assignment upgrades to an array of pointers to the database
elements and converts the Selection Sort and Binary search
procedure on the database to selection sort and binary search on
the array of pointers to the database.
Requirements:
Your...
Order up:: Write a program that will be used to keep track of orders placed at a donut shop. There are two types of items that can be ordered: coffee or donuts. Your program will have a class for each order type, and an abstract superclass. Coffee orders are constructed with the following information: quantity (int) - how many coffees are being ordered size (String) - the size of the coffees (all coffees in the order have the same size)...
Java Programming Create a program named MovieTest The program will create 10 Movie objects and place them in an array or ArrayList of type Movie. The program must do the following (all in main): Create an array or ArrayList of type Movie. Use the data in the text file that is in the download for the Movie file to create 10 Movie objects. Store the 10 Movie objects in the array or ArrayList. You MUST use the date in the...
Need help with this C++ assignment, please use comments so I can better understand your code like comments above your function header explaining what the function does and the purpose of each variable. etc. Assignment: Write a C++ program that reads a text file containing a list of movies "Movie_entries.txt" . Each line in the file contains tile, director, genre, year released and running time of a specific movie. Each field is separated by comma. Print out movie titles sorted...