aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2020-12-28 12:50:35 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2020-12-28 12:50:35 +0100
commitbbfea6a58692da47dd6e166dd13cd02dd6d55074 (patch)
treebb06878f2a4ec6ae90671fb8d4bcb7134fd03ce9
parentb3ed778f6452211bc4070ba7644ea3247ad8f234 (diff)
Display content of an album
-rw-r--r--Album.java7
-rw-r--r--jMusicHub.java20
2 files changed, 25 insertions, 2 deletions
diff --git a/Album.java b/Album.java
index 1dd193d..e2de48f 100644
--- a/Album.java
+++ b/Album.java
@@ -27,7 +27,12 @@ public class Album implements Serializable {
public String getArtist(){return artist;}
public Date getDate(){return date;}
- public ArrayList<Song> getSongs(){return songs;}
+ public void getSongs(){
+ for ( Song s : songs ){
+ System.out.println(s);
+ }
+
+ }
public void setId(int id){this.id=id;}
diff --git a/jMusicHub.java b/jMusicHub.java
index 985a6a2..f25fb46 100644
--- a/jMusicHub.java
+++ b/jMusicHub.java
@@ -495,6 +495,21 @@ public class jMusicHub {
}
}
+ public static void contentOfAlbum(ArrayList<Album> albums){
+ Scanner scan = new Scanner(System.in);
+ listById("albums");
+ System.out.println("\nWhich one do you want to see ?");
+ System.out.printf("Album's ID : ");
+ int albumId = scan.nextInt();
+ String trash = scan.nextLine();
+ for ( Album a : albums ){
+ if ( albumId == a.getId() ){
+ System.out.println("\nSongs : \n");
+ a.getSongs();
+ }
+ }
+ }
+
public jMusicHub() {
System.out.println("Welcome to the jMusicHub !\n");
@@ -521,7 +536,7 @@ public class jMusicHub {
switch(userInput) {
case "h" : //page help
- System.out.printf("c: add a new song\na: add a new album\n+: add an existing song to an album\nl: add a new audiobook\n\np: create a new playlist from existing songs and audiobooks\n-: delete a playlist\n\ns: save playlists, albums, songs and audiobooks into the concerned files\n\nS: List all your saved songs\nB: List all your saved audiobooks\nA: List all your saved albums\nP: List all your saved playlists\n\nPS: Print playlists sorted by their name\nPC: Print the content of a playlist\n\nh: print this help screen\nq: quit the program\n");
+ System.out.printf("c: add a new song\na: add a new album\n+: add an existing song to an album\nl: add a new audiobook\n\np: create a new playlist from existing songs and audiobooks\n-: delete a playlist\n\ns: save playlists, albums, songs and audiobooks into the concerned files\n\nS: List all your saved songs\nB: List all your saved audiobooks\nA: List all your saved albums\nP: List all your saved playlists\n\nPS: Print playlists sorted by their name\nPC: Print the content of a playlist\nAC: Print the content of an album\n\nh: print this help screen\nq: quit the program\n");
break;
case "q" : //quit
@@ -651,6 +666,9 @@ public class jMusicHub {
case "PC":
contentOfPlaylist(playlists);
break;
+ case "AC":
+ contentOfAlbum(albums);
+ break;
default :
System.out.println("Unknown command. Type h for help.");
}