-
Notifications
You must be signed in to change notification settings - Fork 0
/
Movie.java
123 lines (112 loc) · 3.24 KB
/
Movie.java
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// -----------------------------------------------------
// Assignment 2 - COMP 249
// Written by: Maëlys Arnaud 40278798
// Due date : March 27, 2024
// -----------------------------------------------------
import java.io.Serializable;
public class Movie implements Serializable{
private static final long serialVersionUID = 1L;
private int year;
private String title;
private int duration; // in minutes
private String genre;
private String rating;
private double score;
private String director;
private String actor1;
private String actor2;
private String actor3;
public Movie (int year, String title, int duration, String genre, String rating, double score, String director, String actor1, String actor2, String actor3) {
this.year = year;
this.title = title;
this.duration = duration;
this.genre = genre;
this.rating = rating;
this.score = score;
this.director = director;
this.actor1 = actor1;
this.actor2 = actor2;
this.actor3 = actor3;
}
public int getYear() {
return this.year;
}
public String getTitle() {
return this.title;
}
public int getDuration() {
return this.duration;
}
public String getGenre() {
return this.genre;
}
public String getRating() {
return this.rating;
}
public double getScore() {
return this.score;
}
public String getDirector() {
return this.director;
}
public String getActor1() {
return this.actor1;
}
public String getActor2() {
return this.actor2;
}
public String getActor3() {
return this.actor3;
}
// setters
public void setYear(int year) {
this.year = year;
}
public void setTitle(String title) {
this.title = title;
}
public void setDuration(int duration) {
this.duration = duration;
}
public void setGenre(String genre) {
this.genre = genre;
}
public void setRating(String rating) {
this.rating = rating;
}
public void getScore(double score) {
this.score = score;
}
public void setDirector(String director) {
this.director = director;
}
public void setActor1(String actor1) {
this.actor1 = actor1;
}
public void setActor2(String actor2) {
this.actor2 = actor2;
}
public void setActor3(String actor3) {
this.actor3 = actor3;
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
else if (this.getClass() != other.getClass())
return false;
else {
Movie otherMovie = (Movie) other; // downcast to use the getters of the Movie class
return (this.year == otherMovie.getYear() && this.title.equals(otherMovie.getTitle())
&& this.duration == otherMovie.getDuration() && this.genre.equals(otherMovie.getGenre())
&& this.rating.equals(otherMovie.getRating()) && this.score == otherMovie.getScore()
&& this.director.equals(otherMovie.getDirector()) && this.actor1.equals(otherMovie.getActor1())
&& this.actor2.equals(otherMovie.getActor2()) && this.actor3.equals(otherMovie.getActor3()));
}
}
@Override
public String toString() {
return year + "," + title + "," + duration + "," + genre + "," + rating + ","
+ score + "," + director + "," + actor1 + "," + actor2 + "," + actor3;
}
}