forked from erasmuss22/Music-Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Song.java
88 lines (75 loc) · 1.89 KB
/
Song.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
/**
* The title, album title, artist, and musical genre of a single song.
* <p>
* <strong>Do not modify this file in any way!</strong>
*
* @author Ben Liblit
*/
public class Song {
/** title of the album on which this song appears */
private final String album;
/** name of the artist who performed this song */
private final String artist;
/** musical genre of this song */
private final String genre;
/** title of this song */
private final String title;
/**
* Create a new Song with the given title, album title, artist, and genre.
*
* @param title title of this song
* @param album title of the album on which this song appears
* @param artist name of the artist who performed this song
* @param genre musical genre of this song
*/
public Song(String title, String album, String artist, String genre) {
this.title = title;
this.album = album;
this.artist = artist;
this.genre = genre;
}
/**
* @return album on which this song appears
*/
public String getAlbum() {
return album;
}
/**
* @return artist who performed this song
*/
public String getArtist() {
return artist;
}
/**
* @return musical genre of this song
*/
public String getGenre() {
return genre;
}
/**
* @return title of this song
*/
public String getTitle() {
return title;
}
/**
* Test whether this song and another object are both equivalent
* songs, with matching titles, album titles, artists, and genres.
*
* @return true iff they are the same song
*/
@Override
public boolean equals(Object other) {
if (!(other instanceof Song))
return false;
Song song = (Song) other;
return song.getTitle().equals(title)
&& song.getArtist().equals(artist)
&& song.getAlbum().equals(album)
&& song.getGenre().equals(genre);
}
@Override
public String toString() {
return String.format("\"%s\" (%s) by %s on \"%s\"", title, genre, artist, album);
}
}