Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the prompt You task is to develop a similar version of a movies queue. T

ID: 3640459 • Letter: T

Question

This is the prompt
You task is to develop a similar version of a movies queue. The Netflix queue also allows users to move movies up and down the queue, this is not something you will be required to do. Instead, your program will have the following features:

User Interface: You will develop a program to maintain an user's movie queue. The interface should have two sections: Movies Library and Movies Queue. In the movies library the user will be presented with a collection of movies (which you should pre-populate) and the option to add them to the queue. This movies list should be persistent and extensible (that is, one should be able to add more movies), which means the list should be kept on a file. Movies will have the following attributes:
Title
Actors
Director
Genre
The Movie Library should be searchable and sortable per each of these attributes.
Standard Queue Behavior: To begin with, you will provide an interface for users to maintain a simple queue, just as Netflix's, with the exception that your queue and library will have a limit of 50 movies each.
Currently Out Section: The program will simulate a movie being at the user's home by displaying one of the movies in a section called Currently Out, visible at the same screen as the queue. There should be an action called send back, which will remove the movie from the section Currently Out, and remove the movie from the top of the queue, placing it in the section Currently Out, thus simjulating the user sending back the movie and getting the next one in the mail.
Persistency:
The user's queue should also be persistent (just as the movies library), which means it must be saved upon closing the program, and reloaded when the program is re-run.
For this task, you are expected to make use of the data structure studied in class: Arrays.

As for the user interface, you are required no more than a text-based interface.

this is the code i have so far


package netflix;
import java.io.*;
import java.util.*;


public class MovieLibrary {
java.util.ArrayList movieList;
String moviesListFile;

MovieLibrary(String fileName) {
this.moviesListFile = fileName;
loadMovieTitles();
inputQueue();
}

// Note : Data in file must use comma delimmiter to seperate data in each column.
void loadMovieTitles() {

try {
// Create FileReader Object
FileInputStream inputFileReader = new FileInputStream(moviesListFile);

DataInputStream in = new DataInputStream(inputFileReader);
BufferedReader inputStream = new BufferedReader(
new InputStreamReader(in));

String inLine = null;
while ((inLine = inputStream.readLine()) != null) {
// If just seperated by space replace delimitter with prefered below.
StringTokenizer token = new StringTokenizer(inLine, ";");

String title = token.nextToken();
String actors = token.nextToken();
String director = token.nextToken();
String genre = token.nextToken();
if (movieList == null) {
movieList = new java.util.ArrayList();
}

movieList.add(Movie.addMovieByFile(title, actors, director, genre));
}
} catch (Exception e) {
System.out.println(" Errors reading Library file : " + e.getMessage());
}
displayQueue();
}

void displayQueue() {
java.util.Iterator it = movieList.iterator();
int index = 0;
System.out.println(" Stored Movie Titles from File "+moviesListFile);
System.out.println("=================================================");
while (it.hasNext()) {
Movie m = (Movie) it.next();
index++;
System.out.println(index
+ " " + m.title + " " + " " + m.actors
+ " " + m.director + " " + m.genre);

}
}

void updateLibrary() {
try {
FileWriter fstream = new FileWriter(moviesListFile);
BufferedWriter out = new BufferedWriter(fstream);
java.util.Iterator it = movieList.iterator();
while (it.hasNext()) {
Movie m = (Movie) it.next();
out.write(m.title+";"+m.actors+";"+m.director+";"+m.genre);
out.newLine();
}
out.close();
} catch (Exception e) {
System.out.println("Library storage Exception : " + e.getMessage());
}
}

void LibraryMenu() {
System.out.println();
System.out.println("Menu---");
System.out.println("1. Movies Library.");
System.out.println("2. Movies Queue.");
System.out.println("3. Exit. ");
System.out.print("Enter User Option : ");
}

public void inputQueue() {
java.util.Scanner input = new java.util.Scanner(System.in);
LibraryMenu();
String userInput = "";
while (!userInput.equals("3")) {
userInput = input.next();

if (userInput.equals("1")) {
displayQueue();
} else if (userInput.equals("2")) {
System.out.println(" Add Movie : ");
if (movieList == null) {
movieList = new java.util.ArrayList();
}
movieList.add(Movie.addMovie());
updateLibrary();
displayQueue();
}
LibraryMenu();
}
}

private static class Movie {

private String title;
private String actors;
private String director;
private String genre;

Movie(String title, String actors, String director, String genre) {
this.title = title;
this.actors = actors;
this.director = director;
this.genre = genre;
}

static Movie addMovieByFile(String title, String actors, String director, String genre) {
return new Movie(title, actors, director, genre);
}

static Movie addMovie() {
java.util.Scanner input = new java.util.Scanner(System.in);
String title=null, actors=null, director=null, genre=null;
System.out.print("Enter Title : ");
title = input.nextLine();
System.out.print("Enter Actors : ");
actors = input.nextLine();
System.out.print("Enter Director : ");
director = input.nextLine();
System.out.print("Enter Genre : ");
genre = input.nextLine();

if(title.length()==0)
title="-";
if(actors.length()==0)
actors="-";
if(director.length()==0)
director="-";
if(genre.length()==0)
genre="-";
return new Movie(title, actors, director, genre);
}
}

public static void main(String[] args) {
MovieLibrary library = new MovieLibrary("movies.txt");
}
}

Explanation / Answer

OK I made the updates after reading the assignment one more time.

Java code : http://dl.dropbox.com/u/56476562/NetFlix.html

text file : http://dl.dropbox.com/u/56476562/movies.txt

DON'T FORGET TO RATE!!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote