-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovie.java
More file actions
78 lines (63 loc) · 1.94 KB
/
Movie.java
File metadata and controls
78 lines (63 loc) · 1.94 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
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
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
public class Movie implements Serializable{
private String title, director, duration, year, classification;
public Movie() {
title = "";
director = "";
duration = "";
year = "";
classification = "";
}
public String toString(){
return title + " (" + year + ")";
}
public void setTitle(String title) throws EmptyFieldException{
if(title == null || title.length() == 0)
throw new EmptyFieldException("The title cannot be null");
this.title = title;
}
public String getTitle() {
return title;
}
public void setDirector(String director) throws EmptyFieldException{
if(director == null || director.length() == 0)
throw new EmptyFieldException("The director cannot be null");
this.director = director;
}
public String getDirector() {
return director;
}
public void setDuration(String duration) throws EmptyFieldException{
if(duration == null || duration.length() == 0)
throw new EmptyFieldException("The duration cannot be null");
this.duration = duration;
}
public String getDuration() {
return duration;
}
public void setYear(String year) throws EmptyFieldException{
if(year == null || year.length() == 0)
throw new EmptyFieldException("The year cannot be null");
try {
int i = Integer.parseInt(year);
if(i>2019)
throw new EmptyFieldException("Are you from the future?");
} catch (NumberFormatException | NullPointerException nfe) {
throw new EmptyFieldException("The year must be a number");
}
this.year = year;
}
public String getYear() {
return year;
}
public void setClassification(String classification) throws EmptyFieldException{
if(classification == null || classification.length() == 0)
throw new EmptyFieldException("The classification cannot be null");
this.classification = classification;
}
public String getClassification() {
return classification;
}
}