From bbfea6a58692da47dd6e166dd13cd02dd6d55074 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Mon, 28 Dec 2020 12:50:35 +0100 Subject: Display content of an album --- Album.java | 7 ++++++- jMusicHub.java | 20 +++++++++++++++++++- 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 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 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."); } -- cgit v1.2.3