-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrack.java
More file actions
42 lines (35 loc) · 1.23 KB
/
Copy pathTrack.java
File metadata and controls
42 lines (35 loc) · 1.23 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
//store details of an album track
//store the name of the track (str) and the Duration
public class Track {
//A Track Object is composed of the (str)Title & Duration
private final String title;
private final Duration duration;
//Track constructor
public Track(String title, Duration duration) {
this.title = title;
this.duration = duration;
}
//Acessor methods for Duration & title
public Duration getDuration() {
return duration;
}
public String getTitle() {
return title;
}
//used too format Track's variables, and return a string value
public String stringTrack() {
return duration.stringDuration() + " - " + title;
}
//test harness
public static void main(String[] args) {
Track trackObject = new Track("HOLLOW HUNGER", new Duration(0, 3, 44)); //static definition, can change in the code, dont want too clutter w/ scanners
System.out.println(
"This is a test harness function for the Track class\n Example of stringTrack: " +
trackObject.stringTrack() +
"\nHere is the Duration & Title (getDuration & get Title):\n" +
trackObject.getDuration().stringDuration() +
" - " +
trackObject.getTitle()
);
}
}