-
Notifications
You must be signed in to change notification settings - Fork 0
/
Media.java
110 lines (98 loc) · 2.19 KB
/
Media.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
/* @st20102906 1.0 23/11/2016
*
* Matthew Aaron Roberts, 2016
* Student number: st20102906
*/
package st20102906;
/**
* Media.java - a superclass for various forms of media, including films,
* audio tracks and television programmes.
*
* @author Matthew Roberts
* @version 1.0
* @see Media
*/
public class Media {
// declared private - encapsulation
private String title;
private int yearOfRelease;
private int rating;
/**
* Class constructor specifying common media attributes.
* This class is invoked by subclasses because it shares
* common attributes.
*
* @param title
* @param yearOfRelease
* @param rating
*/
public Media(String title, int yearOfRelease, int rating)
{
this.title = title;
this.yearOfRelease = yearOfRelease;
this.rating = rating;
}
/**
* Sets a value for the title.
*
* @param title
*/
public void setTitle(String title)
{
this.title = title;
}
/**
* Sets a value for the year the media was first released.
*
* @param yearOfRelease
*/
public void setYearOfRelease(int yearOfRelease)
{
this.yearOfRelease = yearOfRelease;
}
/**
* Sets a rating value.
*
* @param rating
*/
public void setRating(int rating)
{
this.rating = rating;
}
/**
* Returns the title as a String.
*
* @return a String value for the title.
*/
public String getTitle()
{
return this.title;
}
/**
* Returns the year the media was first released, as an integer.
*
* @return an integer value representing the year for whence the media was first released.
*/
public int getYearOfRelease()
{
return this.yearOfRelease;
}
/**
* Returns the user-determined rating of the media, as an integer between 1-5.
*
* @return an integer value between 1-5 representing the rating.
*/
public int getRating()
{
return this.rating;
}
/**
* Returns the type of Media object. When a subclass class this method it will
* return the object type of the subclasses, as a String.
* @return a string value for the object type
*/
public String getType()
{
return this.getClass().getSimpleName();
}
}