Complete assignment #1

Merged
peyman merged 8 commits from develop into main 2026-07-18 17:10:55 +00:00
3 changed files with 73 additions and 2 deletions
Showing only changes of commit 2099a1a9f3 - Show all commits
+3 -1
View File
@@ -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);
}
}
+1 -1
View File
@@ -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);
}
}
+69
View File
@@ -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;
}
}