-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSong.java
More file actions
108 lines (95 loc) · 3.7 KB
/
Copy pathSong.java
File metadata and controls
108 lines (95 loc) · 3.7 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.csc365p1;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import java.util.HashMap;
/**
*
* @author seansponsler
*/
public class Song {
public static HashMap<String, String> attributeTitles = new HashMap<>();
static {
attributeTitles.put("songTitle", "Title");
attributeTitles.put("artist", "Artist");
attributeTitles.put("album", "Album");
attributeTitles.put("duration", "Duration");
attributeTitles.put("genre", "Genre");
attributeTitles.put("era", "Era");
}
private String songTitle;
private String artist;
private String album;
private int duration;
private String genre;
private String era;
public Song(String songTitle, String artist, String album, int duration, String genre, String era) {
this.songTitle = songTitle;
this.artist = artist;
this.album = album;
this.duration = duration;
this.genre = genre;
this.era = era;
}
public String getSongTitle() { return songTitle; }
public String getArtist() { return artist; }
public String getAlbum() { return album; }
public int getDuration() { return duration; }
public String getGenre() { return genre; }
public String getEra() { return era; }
public StringProperty getPropertyByName(String name) {
if (name.equals("songTitle")) return new SimpleStringProperty(getSongTitle());
if (name.equals("artist")) return new SimpleStringProperty(getArtist());
if (name.equals("album")) return new SimpleStringProperty(getAlbum());
if (name.equals("duration")) return new SimpleStringProperty(Integer.toString(getDuration()));
if (name.equals("genre")) return new SimpleStringProperty(getGenre());
if (name.equals("era")) return new SimpleStringProperty(getEra());
return null;
}
public void setPropertyByName(String name, String newValue) throws NumberFormatException {
if (name.equals("songTitle")) {
setSongTitle(newValue);
return;
}
if (name.equals("artist")) {
setArtist(newValue);
return;
}
if (name.equals("album")) {
setAlbum(newValue);
return;
}
if (name.equals("duration")) {
setDuration(Integer.parseInt(newValue));
return;
}
if (name.equals("genre")) {
setGenre(newValue);
return;
}
if (name.equals("era")) {
setEra(newValue);
}
}
public void setSongTitle(String newTitle) { this.songTitle = newTitle; }
public void setArtist(String newArtist) { this.artist = newArtist; }
public void setAlbum(String newAlbum) { this.album = newAlbum; }
public void setDuration(int newDuration) { this.duration = newDuration; }
public void setGenre(String newGenre) { this.genre = newGenre; }
public void setEra(String newEra) { this.era = newEra; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Song song = (Song) o;
return this.songTitle.equals(song.getSongTitle()) &&
this.artist.equals(song.getArtist()) &&
this.album.equals(song.getAlbum()) &&
this.duration == song.getDuration() &&
this.genre.equals(song.getGenre()) &&
this.era.equals(song.getEra());
}
}