Repository navigation
Expand file tree
/
Copy pathItem.java
More file actions
76 lines (69 loc) · 1.64 KB
/
Copy pathItem.java
File metadata and controls
76 lines (69 loc) · 1.64 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
/**
* Creates an item containing a song name, an artist, a filename and the duration
* of the song.
* @version 1.0
*
* @author S. Larsson<br> A. Ebeling<br> M. Tijanic
*/
public class Item implements Comparable <Item>{
/**
* Name of song.
*/
public String songName;
/**
* Name of artist.
*/
public String artist;
/**
* Name of file.
*/
public String fileName;
/**
* Duration of song.
*/
public String songDuration;
/**
* Class constructor.
* @param theArtist The artist who created the song.
* @param theSongName The song which is to be added to the Item.
* @param theSongDuration The duration of the song.
* @param theFileName The filename of the song.
*
* @version 1.0
* @author S. Larsson<br> A. Ebeling<br> M. Tijanic
*/
public Item(String theArtist, String theSongName, String theSongDuration, String theFileName) {
songName = theSongName;
artist = theArtist;
songDuration = theSongDuration;
fileName = theFileName;
}
/**
* Get the song name.
* @return Item name.
*/
public String getSongName() {
return songName;
}
/**
* Get the filename.
* @return Filename.
*/
public String getFileName() {
return fileName;
}
/**
* Compare song name, here Comparable is implemented.
* @see <a href = https://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html>Comparable</a>
*/
public int compareTo( Item other)
{
return getSongName().compareTo(other.getSongName());
}
/**
* Print as a string.
*/
public String toString() {
return artist + " - "+ songName + "(" + songDuration + ")";
}
}