-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserMovieRating.java
More file actions
50 lines (41 loc) · 1.08 KB
/
UserMovieRating.java
File metadata and controls
50 lines (41 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* SD2x Homework #5
* This class represents a single rating for a movie.
* Please do not change this code! Your solution will be evaluated using this version of the class.
*/
public class UserMovieRating implements Comparable<UserMovieRating> {
protected String movie;
protected int userRating;
public UserMovieRating(String movie, int userRating) {
this.movie = movie;
this.userRating = userRating;
}
public String getMovie() {
return movie;
}
public int getUserRating() {
return userRating;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
UserMovieRating other = (UserMovieRating) obj;
if (movie == null) {
if (other.movie != null)
return false;
} else if (!movie.equals(other.movie))
return false;
if (userRating != other.userRating)
return false;
return true;
}
@Override
public int compareTo(UserMovieRating other) {
return this.userRating - other.userRating;
}
}