-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrack.java
More file actions
41 lines (35 loc) · 1.06 KB
/
Track.java
File metadata and controls
41 lines (35 loc) · 1.06 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
public class Track {
private String title;
private Duration duration;
public static void main(String[] args) {
//TEST HARNESS
Track t1 = new Track("Test Track","00:03:45");
Track t2 = new Track();
t1.getTitle();
t1.getDuration();
t1.toString();
}
//Returns the title of the Track
public String getTitle() {
return title;
}
//Returns the duration of the Track
public Duration getDuration() {
return duration;
}
//Constructor for Track object that takes title and duration as String arguments
public Track(String title, String duration) {
this.title = title;
this.duration = new Duration(duration);
}
//Default constructor for Track
public Track() {
this.title = null;
this.duration = null;
}
//toString method in order to return details about a Track in String format
public String toString() {
String stringDuration = this.duration.toString();
return title + " : " + stringDuration;
}
}