usflix
Class MovieDatabase

java.lang.Object
  extended by usflix.MovieDatabase

public class MovieDatabase
extends java.lang.Object

MovieDatabase class manages movie database and provides search methods.

Version:
4.0 April 3, 2013.
Author:
EJ Jung

Field Summary
private  java.util.ArrayList<Movie> movies
          ArrayList to hold all the movie objects
 
Constructor Summary
MovieDatabase()
          Constructor without parameter.
MovieDatabase(java.lang.String filename)
          Default constructor for MovieDatabase.
 
Method Summary
 boolean addMovie(Movie m)
          Add a new movie object m to the database (ArrayList)
 Movie getMovieByTitle(java.lang.String title)
          This method is used in Driver to assist loadUsers method.
 java.util.ArrayList<Movie> searchByTitle(java.lang.String[] keywords)
          Search for the movies that contain all the keywords given in the parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

movies

private java.util.ArrayList<Movie> movies
ArrayList to hold all the movie objects

Constructor Detail

MovieDatabase

public MovieDatabase()
Constructor without parameter. Initialize movies to be an empty ArrayList.


MovieDatabase

public MovieDatabase(java.lang.String filename)
Default constructor for MovieDatabase.

Parameters:
filename - The file that contains Movie information
Method Detail

addMovie

public boolean addMovie(Movie m)
Add a new movie object m to the database (ArrayList)

Parameters:
m - A new Movie object
Returns:
true if m is added to the database successfully, false otherwise

searchByTitle

public java.util.ArrayList<Movie> searchByTitle(java.lang.String[] keywords)
Search for the movies that contain all the keywords given in the parameter. Returns ArrayList of all matching Movie objects.

Parameters:
keywords - array of keywords
Returns:
ArrayList that contains the Movie objects that match all keywords

getMovieByTitle

public Movie getMovieByTitle(java.lang.String title)
This method is used in Driver to assist loadUsers method. When user information is given in a file, user provides the title and the rating of the movie. This method returns the corresponding movie object for the given title.

Parameters:
title - movie title
Returns:
Movie returns the first Movie object that matches the given title. if none matches, then return null.