usflix
Class User

java.lang.Object
  extended by usflix.User

public class User
extends java.lang.Object

User class manages user information, and provides user account related methods.

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

Field Summary
private  java.lang.String firstName
           
private  java.lang.String lastName
           
private  java.lang.String password
           
private  java.util.ArrayList<MovieRating> seenMovies
          The list of movies that this user has watched and their ratings.
private  java.lang.String username
           
 
Constructor Summary
User(java.lang.String f, java.lang.String l, java.lang.String u, java.lang.String p)
           
 
Method Summary
 void addRating(Movie m, float r)
          When user wishes to rate a movie, this movie may be already in seenMovies.
 java.lang.String getFirstName()
          Get the first name of this user.
 java.lang.String getLastName()
          Get the last name of this user.
 java.lang.String getRating(Movie m)
           
 java.util.ArrayList<Movie> getSeenMovies()
          Create an ArrayList of Movie objects from seenMovies and return the ArrayList.
 boolean login(java.lang.String p)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstName

private java.lang.String firstName

lastName

private java.lang.String lastName

username

private java.lang.String username

password

private java.lang.String password

seenMovies

private java.util.ArrayList<MovieRating> seenMovies
The list of movies that this user has watched and their ratings. To store (movie, rating) pairs, MovieRating class is used.

Constructor Detail

User

public User(java.lang.String f,
            java.lang.String l,
            java.lang.String u,
            java.lang.String p)
Method Detail

login

public boolean login(java.lang.String p)
Parameters:
p - password from login attempt
Returns:
true if the password matches, false otherwise

addRating

public void addRating(Movie m,
                      float r)
When user wishes to rate a movie, this movie may be already in seenMovies. If so, find the corresponding MovieRating object and update the rating in MovieRating object and also update the rating in the Movie object. If this movie is not in seenMovies, then add the rating in the Movie object, create a new MovieRating object and add it to seenMovies.

Parameters:
m -
r - new rating

getRating

public java.lang.String getRating(Movie m)
Parameters:
m -
Returns:
If the user has rated this movie before, return user's rating. Otherwise, return the average rating with (average) tag. For example, if the user has rated the movie to be 3.5 stars, return "3.5". If the user has not rated this movie and the average is 3.3, then return "3.3 (average)"

getFirstName

public java.lang.String getFirstName()
Get the first name of this user.

Returns:
first name

getLastName

public java.lang.String getLastName()
Get the last name of this user.

Returns:
last name

getSeenMovies

public java.util.ArrayList<Movie> getSeenMovies()
Create an ArrayList of Movie objects from seenMovies and return the ArrayList.

Returns:
ArrayList list of seen Movies