-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSong.java
More file actions
74 lines (55 loc) · 1.55 KB
/
Song.java
File metadata and controls
74 lines (55 loc) · 1.55 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
import java.time.LocalDate;
import java.util.*;
class Song implements Comparable<Song> {
private String title;
private String artist;
// private String dateOfPublish;
private int playCount;
private LocalDate date;
public Song(String title, String artist, LocalDate date){
this.title = title;
this.artist = artist;
this.playCount = 0;
this.date = date ;
}
public String getTitle() {
return title;
}
public String getArtist() {
return artist;
}
public LocalDate getDate(){
return date;
}
public int getPlayCount() {
return playCount;
}
public void incrementPlayCount() {
playCount++;
}
public void dateChange( LocalDate date){
this.date = date;
}
@Override
public int compareTo(Song other) {
if (this.playCount != other.playCount) {
return Integer.compare(other.playCount, this.playCount);
}
return this.title.compareToIgnoreCase(other.title);
}
@Override
public String toString() {
return "Title: " + title + ", Artist: " + artist + ", Date: " + date + ", Plays: " + playCount;
}
}
// public Song(String title, String artist, String dateOfPublish) {
// this.title = title;
// this.artist = artist;
// this.dateOfPublish = dateOfPublish;
// this.playCount = 0;
//// if( !date == NULL)
// this.date = LocalDate.now();
// }
// public String getDateOfPublish() {
// return dateOfPublish;
// }