-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSong.java
More file actions
86 lines (69 loc) · 1.8 KB
/
Copy pathSong.java
File metadata and controls
86 lines (69 loc) · 1.8 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
77
78
79
80
81
82
83
84
85
86
package GenderMag2;
import java.util.LinkedList;
public class Song<T> {
// Instance variables
private T name;
private T artist;
private T year;
private T album;
private T songID;
// Constructors
public Song() {
}
public Song(T name, T artist, T year, T album, T songID) {
this.name = name;
this.artist = artist;
this.year = year;
this.album = album;
this.songID = songID;
}
// Getters and Setters
public T getName() {
return this.name;
}
public void setName(T name) {
this.name = name;
}
public T getArtist() {
return this.artist;
}
public void setArtist(T artist) {
this.artist = artist;
}
public T getYear() {
return this.year;
}
public void setYear(T year) {
this.year = year;
}
public T getAlbum() {
return this.album;
}
public void setAlbum(T album) {
this.album = album;
}
public T getSongID() {
return this.songID;
}
public void setSongID(T songID) {
this.songID = songID;
}
// toString
@Override
public String toString() {
return "{" +
" Name='" + getName() + "'" +
", Artist='" + getArtist() + "'" +
", Year='" + getYear() + "'" +
", Album='" + getAlbum() + "'" +
", SongID='" + getSongID() + "'" +
"}";
}
public static <T> void displayAllSongs(LinkedList<Song<T>> songsLinkedList) {
//Print first 3 instances variables of each song
for (int i = 0; i < songsLinkedList.size(); i++) {
Song<T> song = songsLinkedList.get(i);
System.out.println(song.getName() + ", " + song.getArtist() + ", " + song.getYear());
}
}
}