-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrack.java
executable file
·88 lines (80 loc) · 1.94 KB
/
Track.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
/**
* Store the details of a music track,
* such as the artist, title, and file name.
*
* @author David J. Barnes and Michael Kölling
* @version 2016.02.29
*/
public class Track
{
// The artist.
private String artist;
// The track's title.
private String title;
// Where the track is stored.
private String filename;
/**
* Constructor for objects of class Track.
* @param artist The track's artist.
* @param title The track's title.
* @param filename The track file.
*/
public Track(String artist, String title, String filename)
{
setDetails(artist, title, filename);
}
/**
* Constructor for objects of class Track.
* It is assumed that the file name cannot be
* decoded to extract artist and title details.
* @param filename The track file.
*/
public Track(String filename)
{
setDetails("unknown", "unknown", filename);
}
/**
* Return the artist.
* @return The artist.
*/
public String getArtist()
{
return artist;
}
/**
* Return the title.
* @return The title.
*/
public String getTitle()
{
return title;
}
/**
* Return the file name.
* @return The file name.
*/
public String getFilename()
{
return filename;
}
/**
* Return details of the track: artist, title and file name.
* @return The track's details.
*/
public String getDetails()
{
return artist + ": " + title + " (file: " + filename + ")";
}
/**
* Set details of the track.
* @param artist The track's artist.
* @param title The track's title.
* @param filename The track file.
*/
private void setDetails(String artist, String title, String filename)
{
this.artist = artist;
this.title = title;
this.filename = filename;
}
}