diff options
author | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-06-28 23:38:36 +0200 |
---|---|---|
committer | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-06-28 23:38:36 +0200 |
commit | 49196ae84aea338dbc6cd10f4d135e4b717cdd1f (patch) | |
tree | 0c9b9e927aa4d5f35ccc07e45e8abd973b2bad08 /target/site/jacoco/musichub.main/Main.java.html | |
parent | 69247f7a485b1e745d07d2fbd5440b12fa6fce11 (diff) |
Latest package, javadoc and jacocodevelop
Diffstat (limited to 'target/site/jacoco/musichub.main/Main.java.html')
-rw-r--r-- | target/site/jacoco/musichub.main/Main.java.html | 429 |
1 files changed, 236 insertions, 193 deletions
diff --git a/target/site/jacoco/musichub.main/Main.java.html b/target/site/jacoco/musichub.main/Main.java.html index 121cc55..d2b3fb0 100644 --- a/target/site/jacoco/musichub.main/Main.java.html +++ b/target/site/jacoco/musichub.main/Main.java.html @@ -31,7 +31,7 @@ import static musichub.util.Policy.showTerm; <span class="nc bnc" id="L31" title="All 2 branches missed."> if (choice.length() == 0) System.exit(0);</span> <span class="nc bnc" id="L33" title="All 2 branches missed."> while (!choice.equals("")) { //if the user puts nothing, quit the loop/system</span> -<span class="nc bnc" id="L34" title="All 16 branches missed."> switch (choice.charAt(0)) {</span> +<span class="nc bnc" id="L34" title="All 17 branches missed."> switch (choice.charAt(0)) {</span> case 'q': //added the option directly in the switch instead of the loop <span class="nc" id="L36"> System.exit(0);</span> case 'h': @@ -54,240 +54,283 @@ import static musichub.util.Policy.showTerm; <span class="nc" id="L54"> List<Song> songs = theHub.getAlbumSongsSortedByGenre(albumTitle);</span> <span class="nc" id="L55"> System.out.println(songs);</span> <span class="nc" id="L56"> } catch (NoAlbumFoundException ex) {</span> -<span class="nc" id="L57"> System.out.println("No album found with the requested title " + ex.getMessage());</span> -<span class="nc" id="L58"> }</span> -<span class="nc" id="L59"> printAvailableCommands();</span> -<span class="nc" id="L60"> choice = scan.nextLine();</span> -<span class="nc" id="L61"> break;</span> +<span class="nc" id="L57"> LogHandler.write("No album found with the requested title", "WARNING");</span> +<span class="nc" id="L58"> System.out.println("No album found with the requested title " + ex.getMessage());</span> +<span class="nc" id="L59"> }</span> +<span class="nc" id="L60"> printAvailableCommands();</span> +<span class="nc" id="L61"> choice = scan.nextLine();</span> +<span class="nc" id="L62"> break;</span> case 'd': //songs of an album -<span class="nc" id="L64"> System.out.println("Songs of an album will be displayed; enter the album name, available albums are:");</span> -<span class="nc" id="L65"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span> +<span class="nc" id="L65"> System.out.println("Songs of an album will be displayed; enter the album name, available albums are:");</span> +<span class="nc" id="L66"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span> -<span class="nc" id="L67"> albumTitle = scan.nextLine();</span> +<span class="nc" id="L68"> albumTitle = scan.nextLine();</span> try { -<span class="nc" id="L69"> List<AudioElement> songs = theHub.getAlbumSongs(albumTitle);</span> -<span class="nc" id="L70"> System.out.println(theHub.getAlbumSongs(albumTitle));</span> -<span class="nc" id="L71"> String song = scan.nextLine();</span> -<span class="nc" id="L72"> theHub.getAudioElement(songs, song);</span> -<span class="nc" id="L73"> } catch (NoAlbumFoundException ex) {</span> -<span class="nc" id="L74"> System.out.println("No album found with the requested title " + ex.getMessage());</span> -<span class="nc" id="L75"> }</span> -<span class="nc" id="L76"> printAvailableCommands();</span> -<span class="nc" id="L77"> choice = scan.nextLine();</span> -<span class="nc" id="L78"> break;</span> +<span class="nc" id="L70"> List<AudioElement> songs = theHub.getAlbumSongs(albumTitle);</span> +<span class="nc" id="L71"> System.out.println(theHub.getAlbumSongs(albumTitle));</span> +<span class="nc" id="L72"> String song = scan.nextLine();</span> +<span class="nc" id="L73"> theHub.getAudioElement(songs, song);</span> +<span class="nc" id="L74"> } catch (NoAlbumFoundException ex) {</span> +<span class="nc" id="L75"> LogHandler.write("No album found with the requested title", "WARNING");</span> +<span class="nc" id="L76"> System.out.println("No album found with the requested title " + ex.getMessage());</span> +<span class="nc" id="L77"> }</span> +<span class="nc" id="L78"> printAvailableCommands();</span> +<span class="nc" id="L79"> choice = scan.nextLine();</span> +<span class="nc" id="L80"> break;</span> case 'u': //audiobooks ordered by author -<span class="nc" id="L81"> System.out.println(theHub.getAudiobooksTitlesSortedByAuthor());</span> -<span class="nc" id="L82"> printAvailableCommands();</span> -<span class="nc" id="L83"> choice = scan.nextLine();</span> -<span class="nc" id="L84"> break;</span> +<span class="nc" id="L83"> System.out.println(theHub.getAudiobooksTitlesSortedByAuthor());</span> +<span class="nc" id="L84"> printAvailableCommands();</span> +<span class="nc" id="L85"> choice = scan.nextLine();</span> +<span class="nc" id="L86"> break;</span> case 'c': // add a new song -<span class="nc" id="L87"> System.out.println("Enter a new song: ");</span> -<span class="nc" id="L88"> System.out.println("Song title: ");</span> -<span class="nc" id="L89"> String title = scan.nextLine();</span> -<span class="nc" id="L90"> System.out.println("Song genre (jazz, classic, hiphop, rock, pop, rap):");</span> -<span class="nc" id="L91"> String genre = scan.nextLine();</span> -<span class="nc" id="L92"> System.out.println("Song artist: ");</span> -<span class="nc" id="L93"> String artist = scan.nextLine();</span> -<span class="nc" id="L94"> System.out.println("Song length in seconds: ");</span> -<span class="nc" id="L95"> int length = Integer.parseInt(scan.nextLine());</span> +<span class="nc" id="L89"> System.out.println("Enter a new song: ");</span> +<span class="nc" id="L90"> System.out.println("Song title: ");</span> +<span class="nc" id="L91"> String title = scan.nextLine();</span> +<span class="nc" id="L92"> System.out.println("Song genre (jazz, classic, hiphop, rock, pop, rap):");</span> +<span class="nc" id="L93"> String genre = scan.nextLine();</span> +<span class="nc" id="L94"> System.out.println("Song artist: ");</span> +<span class="nc" id="L95"> String artist = scan.nextLine();</span> -<span class="nc" id="L97"> System.out.println("Song content: ");</span> -<span class="nc" id="L98"> String content = scan.nextLine();</span> -<span class="nc bnc" id="L99" title="All 2 branches missed."> if (!isPathValid(content)) {</span> -<span class="nc" id="L100"> String logMsg = "The music file was not found with the path you've provided or the extension is not .wav";</span> -<span class="nc" id="L101"> LogHandler.write(logMsg, "WARNING"); //write a line in the log file</span> -<span class="nc" id="L102"> System.out.println(logMsg + "\nType h for available commands");</span> -<span class="nc" id="L103"> choice = scan.nextLine();</span> -<span class="nc" id="L104"> break;</span> + int length; + try { +<span class="nc" id="L99"> System.out.println("Song length in seconds: ");</span> +<span class="nc" id="L100"> length = Integer.parseInt(scan.nextLine());</span> +<span class="nc" id="L101"> } catch (NumberFormatException ex) {</span> +<span class="nc" id="L102"> String logMsg = "You've not provided a number for the length.";</span> +<span class="nc" id="L103"> LogHandler.write(logMsg, "ERROR"); //write a line in the log file</span> +<span class="nc" id="L104"> System.err.println(logMsg);</span> +<span class="nc" id="L105"> System.out.println("Type h for available commands");</span> +<span class="nc" id="L106"> choice = scan.nextLine();</span> +<span class="nc" id="L107"> break;</span> +<span class="nc" id="L108"> }</span> + +<span class="nc" id="L110"> System.out.println("Song content: ");</span> +<span class="nc" id="L111"> String content = scan.nextLine();</span> +<span class="nc bnc" id="L112" title="All 2 branches missed."> if (!isPathValid(content)) {</span> +<span class="nc" id="L113"> String logMsg = "The music file cannot be found with the path you've provided or the extension is not .wav";</span> +<span class="nc" id="L114"> LogHandler.write(logMsg, "ERROR"); //write a line in the log file</span> +<span class="nc" id="L115"> System.err.println(logMsg);</span> +<span class="nc" id="L116"> System.out.println("Type h for available commands");</span> +<span class="nc" id="L117"> choice = scan.nextLine();</span> +<span class="nc" id="L118"> break;</span> } -<span class="nc" id="L107"> Song s = new Song(title, artist, length, content, genre);</span> -<span class="nc" id="L108"> theHub.addElement(s);</span> -<span class="nc" id="L109"> System.out.println("New element list: ");</span> -<span class="nc" id="L110"> Iterator<AudioElement> it = theHub.elements();</span> -<span class="nc bnc" id="L111" title="All 2 branches missed."> while (it.hasNext()) System.out.println(it.next().getTitle());</span> -<span class="nc" id="L112"> System.out.println("Song created!");</span> -<span class="nc" id="L113"> printAvailableCommands();</span> -<span class="nc" id="L114"> choice = scan.nextLine();</span> -<span class="nc" id="L115"> break;</span> +<span class="nc" id="L121"> Song s = new Song(title, artist, length, content, genre);</span> +<span class="nc" id="L122"> theHub.addElement(s);</span> +<span class="nc" id="L123"> System.out.println("New element list: ");</span> +<span class="nc" id="L124"> Iterator<AudioElement> it = theHub.elements();</span> +<span class="nc bnc" id="L125" title="All 2 branches missed."> while (it.hasNext()) System.out.println(it.next().getTitle());</span> +<span class="nc" id="L126"> LogHandler.write("Song successfully created", "INFO");</span> +<span class="nc" id="L127"> System.out.println("Song created!");</span> +<span class="nc" id="L128"> printAvailableCommands();</span> +<span class="nc" id="L129"> choice = scan.nextLine();</span> +<span class="nc" id="L130"> break;</span> case 'a': // add a new album -<span class="nc" id="L118"> System.out.println("Enter a new album: ");</span> -<span class="nc" id="L119"> System.out.println("Album title: ");</span> -<span class="nc" id="L120"> String aTitle = scan.nextLine();</span> -<span class="nc" id="L121"> System.out.println("Album artist: ");</span> -<span class="nc" id="L122"> String aArtist = scan.nextLine();</span> -<span class="nc" id="L123"> System.out.println("Album length in seconds: ");</span> -<span class="nc" id="L124"> int aLength = Integer.parseInt(scan.nextLine());</span> -<span class="nc" id="L125"> System.out.println("Album date as YYYY-DD-MM: ");</span> -<span class="nc" id="L126"> String aDate = scan.nextLine();</span> -<span class="nc" id="L127"> Album a = new Album(aTitle, aArtist, aLength, aDate);</span> -<span class="nc" id="L128"> theHub.addAlbum(a);</span> -<span class="nc" id="L129"> System.out.println("New list of albums: ");</span> -<span class="nc" id="L130"> Iterator<Album> ita = theHub.albums();</span> -<span class="nc bnc" id="L131" title="All 2 branches missed."> while (ita.hasNext()) System.out.println(ita.next().getTitle());</span> -<span class="nc" id="L132"> System.out.println("Album created!");</span> -<span class="nc" id="L133"> printAvailableCommands();</span> -<span class="nc" id="L134"> choice = scan.nextLine();</span> -<span class="nc" id="L135"> break;</span> +<span class="nc" id="L133"> System.out.println("Enter a new album: ");</span> +<span class="nc" id="L134"> System.out.println("Album title: ");</span> +<span class="nc" id="L135"> String aTitle = scan.nextLine();</span> +<span class="nc" id="L136"> System.out.println("Album artist: ");</span> +<span class="nc" id="L137"> String aArtist = scan.nextLine();</span> +<span class="nc" id="L138"> System.out.println("Album length in seconds: ");</span> +<span class="nc" id="L139"> int aLength = Integer.parseInt(scan.nextLine());</span> +<span class="nc" id="L140"> System.out.println("Album date as YYYY-DD-MM: ");</span> +<span class="nc" id="L141"> String aDate = scan.nextLine();</span> +<span class="nc" id="L142"> Album a = new Album(aTitle, aArtist, aLength, aDate);</span> +<span class="nc" id="L143"> theHub.addAlbum(a);</span> +<span class="nc" id="L144"> System.out.println("New list of albums: ");</span> +<span class="nc" id="L145"> Iterator<Album> ita = theHub.albums();</span> +<span class="nc bnc" id="L146" title="All 2 branches missed."> while (ita.hasNext()) System.out.println(ita.next().getTitle());</span> +<span class="nc" id="L147"> LogHandler.write("Album successfully created", "INFO");</span> +<span class="nc" id="L148"> System.out.println("Album created!");</span> +<span class="nc" id="L149"> printAvailableCommands();</span> +<span class="nc" id="L150"> choice = scan.nextLine();</span> +<span class="nc" id="L151"> break;</span> case '+': //add a song to an album: -<span class="nc" id="L138"> System.out.println("Add an existing song to an existing album");</span> -<span class="nc" id="L139"> System.out.println("Type the name of the song you wish to add. Available songs: ");</span> -<span class="nc" id="L140"> Iterator<AudioElement> itae = theHub.elements();</span> -<span class="nc bnc" id="L141" title="All 2 branches missed."> while (itae.hasNext()) {</span> -<span class="nc" id="L142"> AudioElement ae = itae.next();</span> -<span class="nc bnc" id="L143" title="All 2 branches missed."> if (ae instanceof Song) System.out.println(ae.getTitle());</span> -<span class="nc" id="L144"> }</span> -<span class="nc" id="L145"> String songTitle = scan.nextLine();</span> +<span class="nc" id="L154"> System.out.println("Add an existing song to an existing album");</span> +<span class="nc" id="L155"> System.out.println("Type the name of the song you wish to add. Available songs: ");</span> +<span class="nc" id="L156"> Iterator<AudioElement> itae = theHub.elements();</span> +<span class="nc bnc" id="L157" title="All 2 branches missed."> while (itae.hasNext()) {</span> +<span class="nc" id="L158"> AudioElement ae = itae.next();</span> +<span class="nc bnc" id="L159" title="All 2 branches missed."> if (ae instanceof Song) System.out.println(ae.getTitle());</span> +<span class="nc" id="L160"> }</span> +<span class="nc" id="L161"> String songTitle = scan.nextLine();</span> -<span class="nc" id="L147"> System.out.println("Type the name of the album you wish to enrich. Available albums: ");</span> -<span class="nc" id="L148"> Iterator<Album> ait = theHub.albums();</span> -<span class="nc bnc" id="L149" title="All 2 branches missed."> while (ait.hasNext()) {</span> -<span class="nc" id="L150"> Album al = ait.next();</span> -<span class="nc" id="L151"> System.out.println(al.getTitle());</span> -<span class="nc" id="L152"> }</span> -<span class="nc" id="L153"> String titleAlbum = scan.nextLine();</span> +<span class="nc" id="L163"> System.out.println("Type the name of the album you wish to enrich. Available albums: ");</span> +<span class="nc" id="L164"> Iterator<Album> ait = theHub.albums();</span> +<span class="nc bnc" id="L165" title="All 2 branches missed."> while (ait.hasNext()) {</span> +<span class="nc" id="L166"> Album al = ait.next();</span> +<span class="nc" id="L167"> System.out.println(al.getTitle());</span> +<span class="nc" id="L168"> }</span> +<span class="nc" id="L169"> String titleAlbum = scan.nextLine();</span> try { -<span class="nc" id="L155"> theHub.addElementToAlbum(songTitle, titleAlbum);</span> -<span class="nc" id="L156"> } catch (NoAlbumFoundException | NoElementFoundException ex) {</span> -<span class="nc" id="L157"> System.out.println(ex.getMessage());</span> -<span class="nc" id="L158"> }</span> -<span class="nc" id="L159"> System.out.println("Song added to the album!");</span> -<span class="nc" id="L160"> printAvailableCommands();</span> -<span class="nc" id="L161"> choice = scan.nextLine();</span> -<span class="nc" id="L162"> break;</span> +<span class="nc" id="L171"> theHub.addElementToAlbum(songTitle, titleAlbum);</span> +<span class="nc" id="L172"> } catch (NoAlbumFoundException | NoElementFoundException ex) {</span> +<span class="nc" id="L173"> System.out.println(ex.getMessage());</span> +<span class="nc" id="L174"> }</span> +<span class="nc" id="L175"> LogHandler.write("Song successfully added to the album", "INFO");</span> +<span class="nc" id="L176"> System.out.println("Song added to the album!");</span> +<span class="nc" id="L177"> printAvailableCommands();</span> +<span class="nc" id="L178"> choice = scan.nextLine();</span> +<span class="nc" id="L179"> break;</span> case 'l': // add a new audiobook -<span class="nc" id="L165"> System.out.println("Enter a new audiobook: ");</span> -<span class="nc" id="L166"> System.out.println("AudioBook title: ");</span> -<span class="nc" id="L167"> String bTitle = scan.nextLine();</span> -<span class="nc" id="L168"> System.out.println("AudioBook category (youth, novel, theater, documentary, speech)");</span> -<span class="nc" id="L169"> String bCategory = scan.nextLine();</span> -<span class="nc" id="L170"> System.out.println("AudioBook artist: ");</span> -<span class="nc" id="L171"> String bArtist = scan.nextLine();</span> -<span class="nc" id="L172"> System.out.println("AudioBook length in seconds: ");</span> -<span class="nc" id="L173"> int bLength = Integer.parseInt(scan.nextLine());</span> -<span class="nc" id="L174"> System.out.println("AudioBook content: ");</span> -<span class="nc" id="L175"> String bContent = scan.nextLine();</span> -<span class="nc" id="L176"> System.out.println("AudioBook language (french, english, italian, spanish, german)");</span> -<span class="nc" id="L177"> String bLanguage = scan.nextLine();</span> -<span class="nc" id="L178"> AudioBook b = new AudioBook(bTitle, bArtist, bLength, bContent, bLanguage, bCategory);</span> -<span class="nc" id="L179"> theHub.addElement(b);</span> -<span class="nc" id="L180"> System.out.println("Audiobook created! New element list: ");</span> -<span class="nc" id="L181"> Iterator<AudioElement> itl = theHub.elements();</span> -<span class="nc bnc" id="L182" title="All 2 branches missed."> while (itl.hasNext()) System.out.println(itl.next().getTitle());</span> -<span class="nc" id="L183"> printAvailableCommands();</span> -<span class="nc" id="L184"> choice = scan.nextLine();</span> -<span class="nc" id="L185"> break;</span> +<span class="nc" id="L182"> System.out.println("Enter a new audiobook: ");</span> +<span class="nc" id="L183"> System.out.println("AudioBook title: ");</span> +<span class="nc" id="L184"> String bTitle = scan.nextLine();</span> +<span class="nc" id="L185"> System.out.println("AudioBook category (youth, novel, theater, documentary, speech)");</span> +<span class="nc" id="L186"> String bCategory = scan.nextLine();</span> +<span class="nc" id="L187"> System.out.println("AudioBook artist: ");</span> +<span class="nc" id="L188"> String bArtist = scan.nextLine();</span> +<span class="nc" id="L189"> System.out.println("AudioBook length in seconds: ");</span> +<span class="nc" id="L190"> int bLength = Integer.parseInt(scan.nextLine());</span> +<span class="nc" id="L191"> System.out.println("AudioBook content: ");</span> +<span class="nc" id="L192"> String bContent = scan.nextLine();</span> +<span class="nc" id="L193"> System.out.println("AudioBook language (french, english, italian, spanish, german)");</span> +<span class="nc" id="L194"> String bLanguage = scan.nextLine();</span> +<span class="nc" id="L195"> AudioBook b = new AudioBook(bTitle, bArtist, bLength, bContent, bLanguage, bCategory);</span> +<span class="nc" id="L196"> theHub.addElement(b);</span> +<span class="nc" id="L197"> LogHandler.write("Audiobook successfully created", "INFO");</span> +<span class="nc" id="L198"> System.out.println("Audiobook created! New element list: ");</span> +<span class="nc" id="L199"> Iterator<AudioElement> itl = theHub.elements();</span> +<span class="nc bnc" id="L200" title="All 2 branches missed."> while (itl.hasNext()) System.out.println(itl.next().getTitle());</span> +<span class="nc" id="L201"> printAvailableCommands();</span> +<span class="nc" id="L202"> choice = scan.nextLine();</span> +<span class="nc" id="L203"> break;</span> case 'p': //create a new playlist from existing elements -<span class="nc" id="L188"> System.out.println("Add an existing song or audiobook to a new playlist");</span> -<span class="nc" id="L189"> System.out.println("Existing playlists:");</span> -<span class="nc" id="L190"> Iterator<PlayList> itpl = theHub.playlists();</span> -<span class="nc bnc" id="L191" title="All 2 branches missed."> while (itpl.hasNext()) {</span> -<span class="nc" id="L192"> PlayList pl = itpl.next();</span> -<span class="nc" id="L193"> System.out.println(pl.getTitle());</span> -<span class="nc" id="L194"> }</span> -<span class="nc" id="L195"> System.out.println("Type the name of the playlist you wish to create:");</span> -<span class="nc" id="L196"> String playListTitle = scan.nextLine();</span> -<span class="nc" id="L197"> PlayList pl = new PlayList(playListTitle);</span> -<span class="nc" id="L198"> theHub.addPlaylist(pl);</span> -<span class="nc" id="L199"> System.out.println("Available elements: ");</span> +<span class="nc" id="L206"> System.out.println("Add an existing song or audiobook to a new playlist");</span> +<span class="nc" id="L207"> System.out.println("Existing playlists:");</span> +<span class="nc" id="L208"> Iterator<PlayList> itpl = theHub.playlists();</span> +<span class="nc bnc" id="L209" title="All 2 branches missed."> while (itpl.hasNext()) {</span> +<span class="nc" id="L210"> PlayList pl = itpl.next();</span> +<span class="nc" id="L211"> System.out.println(pl.getTitle());</span> +<span class="nc" id="L212"> }</span> +<span class="nc" id="L213"> System.out.println("Type the name of the playlist you wish to create:");</span> +<span class="nc" id="L214"> String playListTitle = scan.nextLine();</span> +<span class="nc" id="L215"> PlayList pl = new PlayList(playListTitle);</span> +<span class="nc" id="L216"> theHub.addPlaylist(pl);</span> +<span class="nc" id="L217"> System.out.println("Available elements: ");</span> -<span class="nc" id="L201"> Iterator<AudioElement> itael = theHub.elements();</span> -<span class="nc bnc" id="L202" title="All 2 branches missed."> while (itael.hasNext()) {</span> -<span class="nc" id="L203"> AudioElement ae = itael.next();</span> -<span class="nc" id="L204"> System.out.println(ae.getTitle());</span> -<span class="nc" id="L205"> }</span> -<span class="nc bnc" id="L206" title="All 2 branches missed."> while (choice.charAt(0) != 'n') {</span> -<span class="nc" id="L207"> System.out.println("Type the name of the audio element you wish to add or 'n' to exit:");</span> -<span class="nc" id="L208"> String elementTitle = scan.nextLine();</span> +<span class="nc" id="L219"> Iterator<AudioElement> itael = theHub.elements();</span> +<span class="nc bnc" id="L220" title="All 2 branches missed."> while (itael.hasNext()) {</span> +<span class="nc" id="L221"> AudioElement ae = itael.next();</span> +<span class="nc" id="L222"> System.out.println(ae.getTitle());</span> +<span class="nc" id="L223"> }</span> +<span class="nc bnc" id="L224" title="All 2 branches missed."> while (choice.charAt(0) != 'n') {</span> +<span class="nc" id="L225"> System.out.println("Type the name of the audio element you wish to add or 'n' to exit:");</span> +<span class="nc" id="L226"> String elementTitle = scan.nextLine();</span> try { -<span class="nc" id="L210"> theHub.addElementToPlayList(elementTitle, playListTitle);</span> -<span class="nc" id="L211"> } catch (NoPlayListFoundException | NoElementFoundException ex) {</span> -<span class="nc" id="L212"> System.out.println(ex.getMessage());</span> -<span class="nc" id="L213"> }</span> +<span class="nc" id="L228"> theHub.addElementToPlayList(elementTitle, playListTitle);</span> +<span class="nc" id="L229"> } catch (NoPlayListFoundException | NoElementFoundException ex) {</span> +<span class="nc" id="L230"> System.out.println(ex.getMessage());</span> +<span class="nc" id="L231"> }</span> -<span class="nc" id="L215"> System.out.println("Type y to add a new one, n to end");</span> -<span class="nc" id="L216"> choice = scan.nextLine();</span> -<span class="nc" id="L217"> }</span> -<span class="nc" id="L218"> System.out.println("Playlist created!");</span> -<span class="nc" id="L219"> printAvailableCommands();</span> -<span class="nc" id="L220"> choice = scan.nextLine();</span> -<span class="nc" id="L221"> break;</span> +<span class="nc" id="L233"> System.out.println("Type y to add a new one, n to end");</span> +<span class="nc" id="L234"> choice = scan.nextLine();</span> +<span class="nc" id="L235"> }</span> +<span class="nc" id="L236"> LogHandler.write("Playlist successfully created", "INFO");</span> +<span class="nc" id="L237"> System.out.println("Playlist created!");</span> +<span class="nc" id="L238"> printAvailableCommands();</span> +<span class="nc" id="L239"> choice = scan.nextLine();</span> +<span class="nc" id="L240"> break;</span> case '-': //delete a playlist -<span class="nc" id="L224"> System.out.println("Delete an existing playlist. Available playlists:");</span> -<span class="nc" id="L225"> Iterator<PlayList> itp = theHub.playlists();</span> -<span class="nc bnc" id="L226" title="All 2 branches missed."> while (itp.hasNext()) {</span> -<span class="nc" id="L227"> PlayList p = itp.next();</span> -<span class="nc" id="L228"> System.out.println(p.getTitle());</span> -<span class="nc" id="L229"> }</span> -<span class="nc" id="L230"> String plTitle = scan.nextLine();</span> +<span class="nc" id="L243"> System.out.println("Delete an existing playlist. Available playlists:");</span> +<span class="nc" id="L244"> Iterator<PlayList> itp = theHub.playlists();</span> +<span class="nc bnc" id="L245" title="All 2 branches missed."> while (itp.hasNext()) {</span> +<span class="nc" id="L246"> PlayList p = itp.next();</span> +<span class="nc" id="L247"> System.out.println(p.getTitle());</span> +<span class="nc" id="L248"> }</span> +<span class="nc" id="L249"> String plTitle = scan.nextLine();</span> try { -<span class="nc" id="L232"> theHub.deletePlayList(plTitle);</span> -<span class="nc" id="L233"> } catch (NoPlayListFoundException ex) {</span> -<span class="nc" id="L234"> System.out.println(ex.getMessage());</span> -<span class="nc" id="L235"> }</span> -<span class="nc" id="L236"> System.out.println("Playlist deleted!");</span> -<span class="nc" id="L237"> printAvailableCommands();</span> -<span class="nc" id="L238"> choice = scan.nextLine();</span> -<span class="nc" id="L239"> break;</span> +<span class="nc" id="L251"> theHub.deletePlayList(plTitle);</span> +<span class="nc" id="L252"> } catch (NoPlayListFoundException ex) {</span> +<span class="nc" id="L253"> System.out.println(ex.getMessage());</span> +<span class="nc" id="L254"> }</span> +<span class="nc" id="L255"> LogHandler.write("Playlist successfully deleted", "INFO");</span> +<span class="nc" id="L256"> System.out.println("Playlist deleted!");</span> +<span class="nc" id="L257"> printAvailableCommands();</span> +<span class="nc" id="L258"> choice = scan.nextLine();</span> +<span class="nc" id="L259"> break;</span> case 's': //save elements, albums, playlists -<span class="nc" id="L242"> theHub.saveElements();</span> -<span class="nc" id="L243"> theHub.saveAlbums();</span> -<span class="nc" id="L244"> theHub.savePlayLists();</span> -<span class="nc" id="L245"> System.out.println("Elements, albums and playlists saved!");</span> -<span class="nc" id="L246"> printAvailableCommands();</span> -<span class="nc" id="L247"> choice = scan.nextLine();</span> -<span class="nc" id="L248"> break;</span> +<span class="nc" id="L262"> theHub.saveElements();</span> +<span class="nc" id="L263"> theHub.saveAlbums();</span> +<span class="nc" id="L264"> theHub.savePlayLists();</span> +<span class="nc" id="L265"> LogHandler.write("Elements, albums and playlists successfully saved", "INFO");</span> +<span class="nc" id="L266"> System.out.println("Elements, albums and playlists saved!");</span> +<span class="nc" id="L267"> printAvailableCommands();</span> +<span class="nc" id="L268"> choice = scan.nextLine();</span> +<span class="nc" id="L269"> break;</span> case 'r': //search a music try { -<span class="nc" id="L252"> theHub.searchAudioElement();</span> +<span class="nc" id="L273"> theHub.searchAudioElement();</span> } -<span class="nc" id="L254"> catch (NoElementFoundException e){</span> -<span class="nc" id="L255"> System.err.println(e.getMessage());</span> +<span class="nc" id="L275"> catch (NoElementFoundException e){</span> +<span class="nc" id="L276"> System.err.println(e.getMessage());</span> } -<span class="nc" id="L257"> catch (java.io.FileNotFoundException e){</span> -<span class="nc" id="L258"> System.err.println(e.getMessage()+" Please create a file with the extension .wav inside the song folder at root of the app");</span> -<span class="nc" id="L259"> }</span> -<span class="nc" id="L260"> printAvailableCommands();</span> +<span class="nc" id="L278"> catch (java.io.FileNotFoundException e){</span> +<span class="nc" id="L279"> LogHandler.write("Please create a file with the extension .wav inside the song folder at root of the app", "ERROR");</span> +<span class="nc" id="L280"> System.err.println(e.getMessage() + " Please create a file with the extension .wav inside the song folder at root of the app");</span> +<span class="nc" id="L281"> }</span> +<span class="nc" id="L282"> printAvailableCommands();</span> +<span class="nc" id="L283"> choice = scan.nextLine();</span> +<span class="nc" id="L284"> break;</span> case 'o': //consult the app logs -<span class="nc" id="L263"> LogHandler.read();</span> -<span class="nc" id="L264"> System.out.println("Type h for available commands");</span> -<span class="nc" id="L265"> choice = scan.nextLine();</span> -<span class="nc" id="L266"> break;</span> +<span class="nc" id="L287"> LogHandler.read();</span> +<span class="nc" id="L288"> System.out.println("Type h for available commands");</span> +<span class="nc" id="L289"> choice = scan.nextLine();</span> +<span class="nc" id="L290"> break;</span> + case 'm': + //songs of a playlist +<span class="nc" id="L293"> System.out.println("Songs of a playlist will be displayed; enter the playlist name, available playlists are:");</span> +<span class="nc" id="L294"> System.out.println(theHub.getPlayListsTitles());</span> + +<span class="nc" id="L296"> playListTitle = scan.nextLine();</span> + try { +<span class="nc" id="L298"> List<AudioElement> songs = theHub.getPlayListSongs(playListTitle);</span> +<span class="nc" id="L299"> System.out.println(theHub.getPlayListSongs(playListTitle));</span> +<span class="nc" id="L300"> String song = scan.nextLine();</span> +<span class="nc" id="L301"> theHub.getAudioElement(songs, song);</span> +<span class="nc" id="L302"> } catch (NoPlayListFoundException ex) {</span> +<span class="nc" id="L303"> LogHandler.write("No playlist found with the requested title", "WARNING");</span> +<span class="nc" id="L304"> System.out.println("No playlist found with the requested title " + ex.getMessage());</span> +<span class="nc" id="L305"> }</span> +<span class="nc" id="L306"> printAvailableCommands();</span> +<span class="nc" id="L307"> choice = scan.nextLine();</span> +<span class="nc" id="L308"> break;</span> default: -<span class="nc" id="L269"> break;</span> +<span class="nc" id="L311"> break;</span> } } -<span class="nc" id="L272"> scan.close();</span> -<span class="nc" id="L273"> }</span> +<span class="nc" id="L314"> scan.close();</span> +<span class="nc" id="L315"> }</span> private static void printAvailableCommands() { -<span class="nc" id="L276"> System.out.println("t: display the album titles, ordered by date");</span> -<span class="nc" id="L277"> System.out.println("g: display songs of an album, ordered by genre");</span> -<span class="nc" id="L278"> System.out.println("d: display songs of an album");</span> -<span class="nc" id="L279"> System.out.println("u: display audiobooks ordered by author");</span> -<span class="nc" id="L280"> System.out.println("r: search audio elements");</span> -<span class="nc" id="L281"> System.out.println("c: add a new song");</span> -<span class="nc" id="L282"> System.out.println("a: add a new album");</span> -<span class="nc" id="L283"> System.out.println("+: add a song to an album");</span> -<span class="nc" id="L284"> System.out.println("l: add a new audiobook");</span> -<span class="nc" id="L285"> System.out.println("p: create a new playlist from existing songs and audio books");</span> -<span class="nc" id="L286"> System.out.println("-: delete an existing playlist");</span> -<span class="nc" id="L287"> System.out.println("s: save elements, albums, playlists");</span> -<span class="nc" id="L288"> System.out.println("o: consult the app logs");</span> -<span class="nc" id="L289"> System.out.println("q: quit program");</span> -<span class="nc" id="L290"> }</span> +<span class="nc" id="L318"> System.out.println("t: display the album titles, ordered by date");</span> +<span class="nc" id="L319"> System.out.println("g: display songs of an album, ordered by genre");</span> +<span class="nc" id="L320"> System.out.println("d: display songs of an album");</span> +<span class="nc" id="L321"> System.out.println("u: display audiobooks ordered by author");</span> +<span class="nc" id="L322"> System.out.println("r: search audio elements");</span> +<span class="nc" id="L323"> System.out.println("c: add a new song");</span> +<span class="nc" id="L324"> System.out.println("a: add a new album");</span> +<span class="nc" id="L325"> System.out.println("+: add a song to an album");</span> +<span class="nc" id="L326"> System.out.println("l: add a new audiobook");</span> +<span class="nc" id="L327"> System.out.println("p: create a new playlist from existing songs and audio books");</span> +<span class="nc" id="L328"> System.out.println("m: display songs of a playlist");</span> +<span class="nc" id="L329"> System.out.println("-: delete an existing playlist");</span> +<span class="nc" id="L330"> System.out.println("s: save elements, albums, playlists");</span> +<span class="nc" id="L331"> System.out.println("o: consult the app logs");</span> +<span class="nc" id="L332"> System.out.println("q: quit program");</span> +<span class="nc" id="L333"> }</span> } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html>
\ No newline at end of file |