-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovie.java
110 lines (103 loc) · 1.93 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
/*
* Written by Noah Shaw
*/
public class Movie {
public static final String DELIM = "\t";
//Instance variables
private String name;
private int year;
private int rating;
private String director;
private int gross;
//Constructors
public Movie()
{
this.name = "";
this.year = 0;
this.rating = 1;
this.director = "";
this.gross = 0;
}
public Movie(String aName, int aYear, int aRating, String aDirector, int aGross)
{
this.setName(aName);
this.setYear(aYear);
this.setRating(aRating);
this.setDirector(aDirector);
this.setGross(aGross);
}
//Accessors
public String getName()
{
return this.name;
}
public int getYear()
{
return this.year;
}
public int getRating()
{
return this.rating;
}
public String getDirector()
{
return this.director;
}
public int getGross()
{
return this.gross;
}
//Mutators
public void setName(String aName)
{
this.name = aName;
}
public void setYear(int aYear)
{
if(this.year >= 0)
{
this.year = aYear;
}
}
public void setRating(int aRating)
{
if(aRating >= 1 && aRating <= 5)
{
this.rating = aRating;
}
else
{
this.rating = 1;
}
}
public void setDirector(String aDirector)
{
this.director = aDirector;
}
public void setGross(int aGross)
{
this.gross = aGross;
}
//Methods
public boolean equals(Movie aMovie)
{
return aMovie != null &&
this.name.equalsIgnoreCase(aMovie.getName()) &&
this.year == aMovie.getYear() &&
this.rating == aMovie.getRating() &&
this.director.equalsIgnoreCase(aMovie.getDirector()) &&
this.gross == aMovie.getGross();
}
public boolean compareTo(Movie aMovie)
{
if(aMovie == null)
{
return false;
}
return true;
}
public String toString()
{
return this.name + DELIM + this.year + DELIM + this.rating + DELIM + this.director + DELIM + this.gross;
}
}