-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSong.java
More file actions
124 lines (109 loc) · 2.67 KB
/
Copy pathSong.java
File metadata and controls
124 lines (109 loc) · 2.67 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import java.util.List;
/**
* Class to represent a song and store it's corresponding data
*/
public class Song implements SongInterface{
// array to store data about the song
List<String> data;
// constructor to set the data array
public Song(List<String> data) {
this.data = data;
}
/**
* Compares two song objects based on their energy values
* @return -1 if this object is lower in energy than o, 0 if they are the same, and 1 if otherwise
*/
@Override
public int compareTo(SongInterface o) {
// this is less than that
if (this.getEnergy() < o.getEnergy())
return -1;
// this is greater than that
else if (this.getEnergy() > o.getEnergy())
return 1;
// this is equal to that
else
return 0;
}
/**
* Method to get the title of a song
* @return the title of the song
*/
@Override
public String getTitle() {
// returns the title
return data.get(0);
}
/**
* Method to get the artist of the song
* @return the artist of the song
*/
@Override
public String getArtist() {
// returns the artist
return data.get(1);
}
/**
* Method to get the genres of the song
* @return the genres of the song
*/
@Override
public String getGenres() {
// returns the genres
return data.get(2);
}
/**
* Method to get the year the song was released
* @return the year the song was released
*/
@Override
public int getYear() {
// returns the year as an int
return Integer.valueOf(data.get(3));
}
/**
* Method to get the speed(BPM) of the song
* @return the BPM of the song
*/
@Override
public int getBPM() {
// returns the BPM
return Integer.valueOf(data.get(4));
}
/**
* Method to get the energy of the song
* @return the energy of the song
*/
@Override
public int getEnergy() {
// returns the energy
return Integer.valueOf(data.get(5));
}
/**
* Method to get the danceability of the song
* @return the danceability of the song
*/
@Override
public int getDanceability() {
// returns the danceability
return Integer.valueOf(data.get(6));
}
/**
* Method to get the loudness(dB) of the song
* @return the dB of the song
*/
@Override
public int getLoudness() {
// returns the loudness in dB
return Integer.valueOf(data.get(7));
}
/**
* Method to get the liveness of the song
* @return the liveness of the song
*/
@Override
public int getLiveness() {
// returns the liveness
return Integer.valueOf(data.get(8));
}
}