-
Notifications
You must be signed in to change notification settings - Fork 0
/
Show.java
209 lines (186 loc) · 5.22 KB
/
Show.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/**
* AP CSA 1
* Final Project
* TV Show Manager that allows the user to keep track of their shows
* @author KapilTaspa
* 05/18/23
*/
/* Show class is the object class that creates a Show object with a name, platform, length, rating, year, type, current episode, and if a favorite or not. There are accessors and mutators for each of the instance fields of the show in this class.*/
public class Show
{
//INSTANCE FIELDS
private String name;
private String platform;
private int length;
private int rating;
private int year;
private String type;
private int currentep;
private boolean isfavorite;
//CONSTRUCTORS
/**
* Constructs default show with no name, no platform, length of 0, rating of 0, year of 0, no type, current episode of 0, and not a favorite
*/
public Show() {
name = null;
platform = null;
length = 0;
rating = 0;
year = 0;
type = null;
currentep = 0;
isfavorite = false;
}
/**
* Constructs show with 8 given parameters
* @param name the name of the show
* @param platform the platform in which the show is watched
* @param length the amount of total episodes in the show
* @param rating the rating of the show out of 5
* @param year the year that the show was released
* @param type the type of show
* @param currentep the current episode the user is on
* @param isfavorite is the show a favorite or not by the user
*/
public Show(String name, String platform, int length, int rating, int year, String type, int currentep, boolean isfavorite) {
this.name = name;
this.platform = platform;
this.length = length;
this.rating = rating;
this.year = year;
this.type = type;
this.currentep = currentep;
this.isfavorite = isfavorite;
}
//ACCESSORS (including equals, compareTo and toString)
/**
* Gets the name of the show
* @return the name of the show
*/
public String getName() {
return name;
}
/**
* Gets the platform of the show
* @return the platform of the show
*/
public String getPlatform() {
return platform;
}
/**
* Gets the length of the show
* @return the length of the show
*/
public int getLength() {
return length;
}
/**
* Gets the rating of the show
* @return the rating of the show
*/
public int getRating() {
return rating;
}
/**
* Gets the year of the show
* @return the year of the show
*/
public int getYear() {
return year;
}
/**
* Gets the type of the show
* @return the type of the show
*/
public String getType() {
return type;
}
/**
* Gets the current episode of the show
* @return the current episode of the show
*/
public int getCurrent() {
return currentep;
}
/**
* Gets if the show is a favorite or not
* @return true or false base on favorite
*/
public boolean getFavorite() {
return isfavorite;
}
/**
* Checks if the name of the parameter is equal to name of Show object
* @param o Object that is being checked
* @return true or false if they are equal or not
*/
public boolean equals(Object o) {
Show other = (Show) o;
return this.name == other.name && this.name.equals(other.name);
}
/**
* Compares the name of parameter to name of Show object
* @param o Object that is being compared to
* @return 0 if arg string is equal to this string; a value less thn 0 if item is less; value greater than 0 if item is greater
*/
public int compareTo(Object o) {
Show other = (Show) o;
return this.name.compareTo(other.name);
}
//MUTATORS for each instance field even if not using
/**
* Changes name to given name
* @param newName new name to replace old name
*/
public void newName(String newName) {
name = newName;
}
/**
* Changes platform to given platform
* @param newPlatform new platform to replace old platform
*/
public void newPlatform(String newPlatform) {
platform = newPlatform;
}
/**
* Changes length of show to given length
* @param newLength new length to replace old length
*/
public void newLength(int newLength) {
length = newLength;
}
/**
* Changes rating of show out of 5 to given rating
* @param newRating new rating to replace old rating
*/
public void newRating(int newRating) {
rating = newRating;
}
/**
* Changes year the TV show was made to given year
* @param newYear new year to replace old year
*/
public void newYear(int newYear) {
year = newYear;
}
/**
* Changes type of show to given type
* @param newType new type to replace old type
*/
public void newType(String newType) {
type = newType;
}
/**
* Changes current episode to new episode
* @param newEpisode to replace current episode
*/
public void newEpisode(int newEpisode) {
currentep = newEpisode;
}
/** changes isfavorite to either true or false
* @param newFav to replace current favorite
*/
public void newFavorite(boolean newFav) {
isfavorite = newFav;
}
}