diff options
Diffstat (limited to 'jMusicHub.java')
-rw-r--r-- | jMusicHub.java | 134 |
1 files changed, 113 insertions, 21 deletions
diff --git a/jMusicHub.java b/jMusicHub.java index 363695e..56bb957 100644 --- a/jMusicHub.java +++ b/jMusicHub.java @@ -1,21 +1,37 @@ +/* + * Name : jMusicHub + * + * Description : The jMusicHub class is our main component. It's basically the app we use to launch the whole process + * + * Version : 1.0 + * + * Date : 28/12/2020 + * + * Copyright : Aimeric ADJUTOR + */ + import java.util.*; import java.io.*; import java.text.*; /** - * The jMusicHub class is basically the app. - * It is used to launch the whole process. + * The jMusicHub class is our main component. + * It's basically the app we use to launch the whole process. * * @author Aimeric ADJUTOR * @version 1.0 * @since 2020-11-13 * */ - public class jMusicHub { /** - * addSong is used to add songs thanks to the "c" option - * @param scan Scanner Object + * addSong is used to add songs thanks to the "c" option. + * It prompts to the user a series of interrogations, asks to confirm. + * A new song is then created and returned. + * @param scan Scanner + * @return newSong Song + * @see Song + * @author Aimeric ADJUTOR */ public static Song addSong(Scanner scan){ System.out.println("Adding a song..."); @@ -54,8 +70,13 @@ public class jMusicHub { } /** - * addAudioBook is used to add songs thanks to the "l" option - * @param scan Scanner Object + * addAudioBook is used to add songs thanks to the "l" option. + * It prompts to the user a series of interrogations, asks to confirm. + * A new audiobook is then created and returned. + * @param scan Scanner + * @return newAudioBook AudioBook + * @see AudioBook + * @author Aimeric ADJUTOR */ public static AudioBook addAudioBook(Scanner scan){ System.out.println("Adding an audiobook..."); @@ -99,8 +120,13 @@ public class jMusicHub { } /** - * addAlbum is used to add albums thanks to the "a" option - * @param scan Scanner Object + * addAlbum is used to add albums thanks to the "a" option. + * It prompts to the user a series of interrogations, asks to confirm. + * A new album is then created and returned. + * @param scan Scanner + * @return newAlbum Album + * @see Album + * @author Aimeric ADJUTOR */ public static Album addAlbum(Scanner scan){ System.out.println("\n[DISCLAIMER : You have to register the songs after creating (a) and saving (s) the albums]\n"); @@ -140,8 +166,15 @@ public class jMusicHub { } /** - * addPlaylist is used to add playlist thanks to the "p" option - * @param scan Scanner Object + * addPlaylist is used to add playlist thanks to the "p" option. + * It prompts to the user a series of interrogations, asks to confirm. + * A new playlist is then created and returned. + * @param scan Scanner + * @param songs ArrayList + * @param audiobooks ArrayList + * @return newPlaylist Playlist + * @see Playlist + * @author Aimeric ADJUTOR */ public static Playlist addPlaylist(Scanner scan, ArrayList<Song> songs, ArrayList<AudioBook> audiobooks){ String userInput; @@ -206,12 +239,11 @@ public class jMusicHub { } /** - * save is used by the command "s" - * It is used to serialize (save) arrays of a list into the type's file.i - * Exemple : save("nameOfTheFile", elements) - * It will save the arrayList named elements into nameOfTheFile in the working directory. + * save is used by the command "s". + * It is used to serialize (save) arrays of a list into the type's file. * @param filename String * @param elements ArrayList + * @author Aimeric ADJUTOR * */ @SuppressWarnings ("rawtypes") public static void save(String filename, ArrayList elements){ @@ -239,8 +271,8 @@ public class jMusicHub { /** * list is called when using the "AB", "S", "A" and "P" commands in order to list the elements in respective files. * @param filename String + * @author Aimeric ADJUTOR * */ - public static void listById(String filename){ // Deserialization @@ -308,6 +340,12 @@ public class jMusicHub { catch (ClassNotFoundException ex) {System.out.println("ClassNotFoundException is caught");} } +/** + * listPlaylistsByName is called when using the "PN" command in order to list the playlists sorted by their name. + * To achieve that, I had to put names in uppercase with getName from Playlist. + * @see Playlist#getName + * @author Aimeric ADJUTOR + * */ public static void listPlaylistsByName(){ String filename = "playlists"; try { @@ -330,7 +368,10 @@ public class jMusicHub { catch (IOException ex) {System.out.println(filename+ " file missing.");} catch (ClassNotFoundException ex) {System.out.println("ClassNotFoundException is caught");} } - +/** + * listAlbumsByDate is called by the "AD" command in order to list the albums sorted by the date of release. + * @author Aimeric ADJUTOR + * */ public static void listAlbumsByDate(){ String filename = "albums"; try { @@ -354,6 +395,11 @@ public class jMusicHub { catch (ClassNotFoundException ex) {System.out.println("ClassNotFoundException is caught");} } +/** + * listAlbumsByGenre is called by the "AG" command in order to list the albums sorted by the genre of their songs. + * @see Album#getGenre + * @author Aimeric ADJUTOR + * */ public static void listAlbumsByGenre(){ String filename = "albums"; try { @@ -376,7 +422,10 @@ public static void listAlbumsByGenre(){ catch (IOException ex) {System.out.println(filename+ " file missing.");} catch (ClassNotFoundException ex) {System.out.println("ClassNotFoundException is caught");} } - +/** + * listAudioBooksByAuthor is called by the "BA" command in order to list the audiobooks sorted by authors. + * @author Aimeric ADJUTOR + * */ public static void listAudioBooksByAuthor(){ String filename = "audiobooks"; try { @@ -403,6 +452,8 @@ public static void listAudioBooksByAuthor(){ /** * Extract is used to print the content of the files and put them in the ArrayList used to add elements. * @param filename String + * @return ArrayList + * @author Aimeric ADJUTOR * */ @SuppressWarnings("rawtypes") public static ArrayList extract(String filename){ @@ -484,6 +535,13 @@ public static void listAudioBooksByAuthor(){ } } +/** + * addSongToAlbum is called by the "+" command in order to add a song to an album. + * @param scan Scanner + * @param albums ArrayList + * @param songs ArrayList + * @author Aimeric ADJUTOR + * */ public static void addSongToAlbum(Scanner scan, ArrayList<Album> albums, ArrayList<Song> songs){ System.out.println("Adding a existing song to an existing album..."); listById("songs"); @@ -507,6 +565,12 @@ public static void listAudioBooksByAuthor(){ } } +/** + * delPlaylist is called by the "-" command in order to delete a playlist. + * @param playlists ArrayList + * @return playlists ArrayList + * @author Aimeric ADJUTOR + * */ public static ArrayList<Playlist> delPlaylist(ArrayList<Playlist> playlists){ Scanner scan = new Scanner(System.in); listById("playlists"); @@ -534,6 +598,11 @@ public static void listAudioBooksByAuthor(){ return playlists; } +/** + * contentOfPlaylist is called by the "PC" command in order to display the content of a chosen playlist. + * @param playlists ArrayList + * @author Aimeric ADJUTOR + * */ public static void contentOfPlaylist(ArrayList<Playlist> playlists){ Scanner scan = new Scanner(System.in); listById("playlists"); @@ -550,7 +619,11 @@ public static void listAudioBooksByAuthor(){ } } } - +/** + * contentOfAlbum is called by the "AC" command in order to display the content of a chosen album. + * @param albums ArrayList + * @author Aimeric ADJUTOR + * */ public static void contentOfAlbum(ArrayList<Album> albums){ Scanner scan = new Scanner(System.in); listById("albums"); @@ -566,6 +639,18 @@ public static void listAudioBooksByAuthor(){ } } +/** + * Constructor method, it is calling every methods and contains the command prompt. + * @see Song + * @see AudioBook + * @see Album + * @see Playlist + * @see Genre + * @see Category + * @see Language + * + * @author Aimeric ADJUTOR + * */ public jMusicHub() { System.out.println("Welcome to the jMusicHub !\n"); @@ -592,7 +677,7 @@ public static void listAudioBooksByAuthor(){ 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\nAD: Print albums sorted by their date of release\nAG: Print albums sorted by their genre\nAC: Print the content of an album\nBA: Print audiobooks sorted by their author's name\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\nPN: Print playlists sorted by their name\nPC: Print the content of a playlist\nAD: Print albums sorted by their date of release\nAG: Print albums sorted by their genre\nAC: Print the content of an album\nBA: Print audiobooks sorted by their author's name\n\nh: print this help screen\nq: quit the program\n"); break; case "q" : //quit @@ -716,7 +801,7 @@ public static void listAudioBooksByAuthor(){ case "P": //print playlists sorted by id listById("playlists"); break; - case "PS": //print playlists sorted by their name + case "PN": //print playlists sorted by their name listPlaylistsByName(); break; case "PC": //display content of a chosen playlist @@ -739,6 +824,13 @@ public static void listAudioBooksByAuthor(){ } } while(!userInput.equals("q")); } + +/** + * The main method is used to launch the app. + * @param args String[] + * @author Aimeric ADJUTOR + * */ + public static void main(String[] args) { new jMusicHub(); } |