Implement Song class
This commit is contained in:
@@ -4,5 +4,7 @@ import javafx.application.Application;
|
||||
|
||||
public class Launcher{
|
||||
public static void main(String[] args) {
|
||||
// TODO: Launch the JavaFX application by calling Application.launch(Main.class) }
|
||||
// TODO: Launch the JavaFX application by calling Application.launch(Main.class)
|
||||
Application.launch(MusicApp.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ public class MusicApp extends Application {
|
||||
Scene scene = new Scene(fxmlLoader.load());
|
||||
stage.setTitle("Music Player");
|
||||
stage.setScene(scene);
|
||||
//TODO: add icon to the stage
|
||||
stage.show();
|
||||
stage.setResizable(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,73 @@
|
||||
package sbu.javafx;
|
||||
|
||||
public class Song {
|
||||
|
||||
private String title;
|
||||
private String artist;
|
||||
private String album;
|
||||
private String filePath;
|
||||
private String coverPath;
|
||||
private int duration; // seconds
|
||||
|
||||
// Constructor
|
||||
public Song(String title, String artist, String album, String filePath, String coverPath, int duration){
|
||||
this.title = title;
|
||||
this.artist = artist;
|
||||
this.album = album;
|
||||
this.filePath = filePath;
|
||||
this.coverPath = coverPath;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
// ========================================= Getters ============================================
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
public String getCoverPath() {
|
||||
return coverPath;
|
||||
}
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
public String getAlbum() {
|
||||
return album;
|
||||
}
|
||||
public String getArtist() {
|
||||
return artist;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
// ========================================= Setters ============================================
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setArtist(String artist) {
|
||||
this.artist = artist;
|
||||
}
|
||||
public void setAlbum(String album) {
|
||||
this.album = album;
|
||||
}
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
public void setCoverPath(String coverPath) {
|
||||
this.coverPath = coverPath;
|
||||
}
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
// ========================================= Methods ============================================
|
||||
public String formattedDuration(){
|
||||
int minutes = duration / 60;
|
||||
int seconds = duration % 60;
|
||||
return String.format("%d:%02d)", minutes, seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title + " - " + artist;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user