-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDVD.java
More file actions
85 lines (66 loc) · 1.65 KB
/
DVD.java
File metadata and controls
85 lines (66 loc) · 1.65 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
79
80
81
82
83
84
85
//Andrew Clear, Lab03
/**This class creates the DVD objects
* @author aclear16
*/
public class DVD extends MediaItem {
private String studio;
private int acting;
private int directing;
private int soundtrack;
/**The DVD constructor
* @param title
* @param price
* @param stu
*/
public DVD(String title, double price, String stu) {
super(title,price);
this.studio = stu;
}
/* Formats the toString method to be nicely displayed in the GUI
* and truncates the title at 45 characters
* (non-Javadoc)
* @see MediaItem#toString()
*/
@Override
public String toString() {
String shortTitle = this.getTitle();
if (this.getTitle().length() > 45) {
shortTitle = shortTitle.substring(0, 42);
shortTitle = shortTitle.concat("...");
}
return String.format("DVD [%.2f] $%-7.2f '%-45s' (acting=%s, direct=%s, soundt=%s)", this.overallRating(),
this.getPrice(), shortTitle, this.acting, this.directing, this.soundtrack);
}
/* Calculates the average rating
* (non-Javadoc)
* @see MediaItem#overallRating()
*/
@Override
public double overallRating() {
return (double)(this.acting + this.directing + this.soundtrack) / 3;
}
public String getStudio() {
return studio;
}
public int getActing() {
return acting;
}
public int getDirecting() {
return directing;
}
public int getSoundtrack() {
return soundtrack;
}
public void setStudio(String studio) {
this.studio = studio;
}
public void setActing(int acting) {
this.acting = acting;
}
public void setDirecting(int directing) {
this.directing = directing;
}
public void setSoundtrack(int soundtrack) {
this.soundtrack = soundtrack;
}
}