-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMovie.java
More file actions
42 lines (35 loc) Β· 918 Bytes
/
Copy pathMovie.java
File metadata and controls
42 lines (35 loc) Β· 918 Bytes
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
package day10;
public class Movie implements Comparable<Movie> {
String name;
int year;
double imdbRating;
public Movie(String name, int year, double imdbRating) {
this.name = name;
this.year = year;
this.imdbRating = imdbRating;
}
@Override
public int compareTo(Movie other) {
if (this.name.equals(other.name)) {
return Double.compare(other.imdbRating, this.imdbRating);
}
return this.name.compareTo(other.name);
}
@Override
public String toString() {
return "Movie{" +
"name='" + name + '\'' +
", year=" + year +
", imdbRating=" + imdbRating +
'}';
}
public String getName() {
return name;
}
public double getImdbRating() {
return imdbRating;
}
public int getYear() {
return year;
}
}