aboutsummaryrefslogtreecommitdiff
path: root/target/site/jacoco/musichub.main/Main.java.html
diff options
context:
space:
mode:
Diffstat (limited to 'target/site/jacoco/musichub.main/Main.java.html')
-rw-r--r--target/site/jacoco/musichub.main/Main.java.html410
1 files changed, 210 insertions, 200 deletions
diff --git a/target/site/jacoco/musichub.main/Main.java.html b/target/site/jacoco/musichub.main/Main.java.html
index df39af0..7ec6a41 100644
--- a/target/site/jacoco/musichub.main/Main.java.html
+++ b/target/site/jacoco/musichub.main/Main.java.html
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="fr"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>Main.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">spoteezer</a> &gt; <a href="index.source.html" class="el_package">musichub.main</a> &gt; <span class="el_source">Main.java</span></div><h1>Main.java</h1><pre class="source lang-java linenums">package musichub.main;
import musichub.business.*;
+import musichub.util.LogHandler;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -9,258 +10,267 @@ import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
-import static musichub.business.PathValidation.isPathValid;
+import static musichub.util.PathValidation.isPathValid;
-<span class="nc" id="L14">public class Main {</span>
+<span class="nc" id="L15">public class Main {</span>
public static void main(String[] args) throws UnsupportedAudioFileException, IOException, LineUnavailableException {
-<span class="nc" id="L17"> MusicHub theHub = new MusicHub();</span>
+<span class="nc" id="L18"> MusicHub theHub = new MusicHub();</span>
-<span class="nc" id="L19"> System.out.println(&quot;Type h for available commands&quot;);</span>
+<span class="nc" id="L20"> System.out.println(&quot;Type h for available commands&quot;);</span>
-<span class="nc" id="L22"> Scanner scan = new Scanner(System.in);</span>
-<span class="nc" id="L23"> String choice = scan.nextLine();</span>
+<span class="nc" id="L23"> Scanner scan = new Scanner(System.in);</span>
+<span class="nc" id="L24"> String choice = scan.nextLine();</span>
String albumTitle;
-<span class="nc bnc" id="L27" title="All 2 branches missed."> if (choice.length() == 0) System.exit(0);</span>
+<span class="nc bnc" id="L28" title="All 2 branches missed."> if (choice.length() == 0) System.exit(0);</span>
-<span class="nc bnc" id="L29" title="All 2 branches missed."> while (!choice.equals(&quot;&quot;)) { //if the user puts nothing, quit the loop/system</span>
-<span class="nc bnc" id="L30" title="All 14 branches missed."> switch (choice.charAt(0)) {</span>
+<span class="nc bnc" id="L30" title="All 2 branches missed."> while (!choice.equals(&quot;&quot;)) { //if the user puts nothing, quit the loop/system</span>
+<span class="nc bnc" id="L31" title="All 15 branches missed."> switch (choice.charAt(0)) {</span>
case 'q': //added the option directly in the switch instead of the loop
-<span class="nc" id="L32"> System.exit(0);</span>
+<span class="nc" id="L33"> System.exit(0);</span>
case 'h':
-<span class="nc" id="L34"> printAvailableCommands();</span>
-<span class="nc" id="L35"> choice = scan.nextLine();</span>
-<span class="nc" id="L36"> break;</span>
+<span class="nc" id="L35"> printAvailableCommands();</span>
+<span class="nc" id="L36"> choice = scan.nextLine();</span>
+<span class="nc" id="L37"> break;</span>
case 't':
//album titles, ordered by date
-<span class="nc" id="L39"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span>
-<span class="nc" id="L40"> printAvailableCommands();</span>
-<span class="nc" id="L41"> choice = scan.nextLine();</span>
-<span class="nc" id="L42"> break;</span>
+<span class="nc" id="L40"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span>
+<span class="nc" id="L41"> printAvailableCommands();</span>
+<span class="nc" id="L42"> choice = scan.nextLine();</span>
+<span class="nc" id="L43"> break;</span>
case 'g':
//songs of an album, sorted by genre
-<span class="nc" id="L45"> System.out.println(&quot;Songs of an album sorted by genre will be displayed; enter the album name, available albums are:&quot;);</span>
-<span class="nc" id="L46"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span>
+<span class="nc" id="L46"> System.out.println(&quot;Songs of an album sorted by genre will be displayed; enter the album name, available albums are:&quot;);</span>
+<span class="nc" id="L47"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span>
-<span class="nc" id="L48"> albumTitle = scan.nextLine();</span>
+<span class="nc" id="L49"> albumTitle = scan.nextLine();</span>
try {
-<span class="nc" id="L50"> List&lt;Song&gt; songs = theHub.getAlbumSongsSortedByGenre(albumTitle);</span>
-<span class="nc" id="L51"> System.out.println(songs);</span>
-<span class="nc" id="L52"> } catch (NoAlbumFoundException ex) {</span>
-<span class="nc" id="L53"> System.out.println(&quot;No album found with the requested title &quot; + ex.getMessage());</span>
-<span class="nc" id="L54"> }</span>
-<span class="nc" id="L55"> printAvailableCommands();</span>
-<span class="nc" id="L56"> choice = scan.nextLine();</span>
-<span class="nc" id="L57"> break;</span>
+<span class="nc" id="L51"> List&lt;Song&gt; songs = theHub.getAlbumSongsSortedByGenre(albumTitle);</span>
+<span class="nc" id="L52"> System.out.println(songs);</span>
+<span class="nc" id="L53"> } catch (NoAlbumFoundException ex) {</span>
+<span class="nc" id="L54"> System.out.println(&quot;No album found with the requested title &quot; + ex.getMessage());</span>
+<span class="nc" id="L55"> }</span>
+<span class="nc" id="L56"> printAvailableCommands();</span>
+<span class="nc" id="L57"> choice = scan.nextLine();</span>
+<span class="nc" id="L58"> break;</span>
case 'd':
//songs of an album
-<span class="nc" id="L60"> System.out.println(&quot;Songs of an album will be displayed; enter the album name, available albums are:&quot;);</span>
-<span class="nc" id="L61"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span>
+<span class="nc" id="L61"> System.out.println(&quot;Songs of an album will be displayed; enter the album name, available albums are:&quot;);</span>
+<span class="nc" id="L62"> System.out.println(theHub.getAlbumsTitlesSortedByDate());</span>
-<span class="nc" id="L63"> albumTitle = scan.nextLine();</span>
+<span class="nc" id="L64"> albumTitle = scan.nextLine();</span>
try {
-<span class="nc" id="L65"> List&lt;AudioElement&gt; songs = theHub.getAlbumSongs(albumTitle);</span>
-<span class="nc" id="L66"> System.out.println(theHub.getAlbumSongs(albumTitle));</span>
-<span class="nc" id="L67"> String song = scan.nextLine();</span>
-<span class="nc" id="L68"> theHub.getAudioElement(songs, song);</span>
-<span class="nc" id="L69"> } catch (NoAlbumFoundException ex) {</span>
-<span class="nc" id="L70"> System.out.println(&quot;No album found with the requested title &quot; + ex.getMessage());</span>
-<span class="nc" id="L71"> }</span>
-<span class="nc" id="L72"> printAvailableCommands();</span>
-<span class="nc" id="L73"> choice = scan.nextLine();</span>
-<span class="nc" id="L74"> break;</span>
+<span class="nc" id="L66"> List&lt;AudioElement&gt; songs = theHub.getAlbumSongs(albumTitle);</span>
+<span class="nc" id="L67"> System.out.println(theHub.getAlbumSongs(albumTitle));</span>
+<span class="nc" id="L68"> String song = scan.nextLine();</span>
+<span class="nc" id="L69"> theHub.getAudioElement(songs, song);</span>
+<span class="nc" id="L70"> } catch (NoAlbumFoundException ex) {</span>
+<span class="nc" id="L71"> System.out.println(&quot;No album found with the requested title &quot; + ex.getMessage());</span>
+<span class="nc" id="L72"> }</span>
+<span class="nc" id="L73"> printAvailableCommands();</span>
+<span class="nc" id="L74"> choice = scan.nextLine();</span>
+<span class="nc" id="L75"> break;</span>
case 'u':
//audiobooks ordered by author
-<span class="nc" id="L77"> System.out.println(theHub.getAudiobooksTitlesSortedByAuthor());</span>
-<span class="nc" id="L78"> printAvailableCommands();</span>
-<span class="nc" id="L79"> choice = scan.nextLine();</span>
-<span class="nc" id="L80"> break;</span>
+<span class="nc" id="L78"> System.out.println(theHub.getAudiobooksTitlesSortedByAuthor());</span>
+<span class="nc" id="L79"> printAvailableCommands();</span>
+<span class="nc" id="L80"> choice = scan.nextLine();</span>
+<span class="nc" id="L81"> break;</span>
case 'c':
// add a new song
-<span class="nc" id="L83"> System.out.println(&quot;Enter a new song: &quot;);</span>
-<span class="nc" id="L84"> System.out.println(&quot;Song title: &quot;);</span>
-<span class="nc" id="L85"> String title = scan.nextLine();</span>
-<span class="nc" id="L86"> System.out.println(&quot;Song genre (jazz, classic, hiphop, rock, pop, rap):&quot;);</span>
-<span class="nc" id="L87"> String genre = scan.nextLine();</span>
-<span class="nc" id="L88"> System.out.println(&quot;Song artist: &quot;);</span>
-<span class="nc" id="L89"> String artist = scan.nextLine();</span>
-<span class="nc" id="L90"> System.out.println(&quot;Song length in seconds: &quot;);</span>
-<span class="nc" id="L91"> int length = Integer.parseInt(scan.nextLine());</span>
+<span class="nc" id="L84"> System.out.println(&quot;Enter a new song: &quot;);</span>
+<span class="nc" id="L85"> System.out.println(&quot;Song title: &quot;);</span>
+<span class="nc" id="L86"> String title = scan.nextLine();</span>
+<span class="nc" id="L87"> System.out.println(&quot;Song genre (jazz, classic, hiphop, rock, pop, rap):&quot;);</span>
+<span class="nc" id="L88"> String genre = scan.nextLine();</span>
+<span class="nc" id="L89"> System.out.println(&quot;Song artist: &quot;);</span>
+<span class="nc" id="L90"> String artist = scan.nextLine();</span>
+<span class="nc" id="L91"> System.out.println(&quot;Song length in seconds: &quot;);</span>
+<span class="nc" id="L92"> int length = Integer.parseInt(scan.nextLine());</span>
-<span class="nc" id="L93"> System.out.println(&quot;Song content: &quot;);</span>
-<span class="nc" id="L94"> String content = scan.nextLine();</span>
-<span class="nc bnc" id="L95" title="All 2 branches missed."> if (!isPathValid(content)) {</span>
-<span class="nc" id="L96"> System.out.println(&quot;The music file was not found with the path you've provided.\nType h for available commands&quot;);</span>
-<span class="nc" id="L97"> choice = scan.nextLine();</span>
-<span class="nc" id="L98"> break;</span>
+<span class="nc" id="L94"> System.out.println(&quot;Song content: &quot;);</span>
+<span class="nc" id="L95"> String content = scan.nextLine();</span>
+<span class="nc bnc" id="L96" title="All 2 branches missed."> if (!isPathValid(content)) {</span>
+<span class="nc" id="L97"> String logMsg = &quot;The music file was not found with the path you've provided.&quot;;</span>
+<span class="nc" id="L98"> LogHandler.write(logMsg, &quot;WARNING&quot;); //write a line in the log file</span>
+<span class="nc" id="L99"> System.out.println(logMsg + &quot;\nType h for available commands&quot;);</span>
+<span class="nc" id="L100"> choice = scan.nextLine();</span>
+<span class="nc" id="L101"> break;</span>
}
-<span class="nc" id="L101"> Song s = new Song(title, artist, length, content, genre);</span>
-<span class="nc" id="L102"> theHub.addElement(s);</span>
-<span class="nc" id="L103"> System.out.println(&quot;New element list: &quot;);</span>
-<span class="nc" id="L104"> Iterator&lt;AudioElement&gt; it = theHub.elements();</span>
-<span class="nc bnc" id="L105" title="All 2 branches missed."> while (it.hasNext()) System.out.println(it.next().getTitle());</span>
-<span class="nc" id="L106"> System.out.println(&quot;Song created!&quot;);</span>
-<span class="nc" id="L107"> printAvailableCommands();</span>
-<span class="nc" id="L108"> choice = scan.nextLine();</span>
-<span class="nc" id="L109"> break;</span>
+<span class="nc" id="L104"> Song s = new Song(title, artist, length, content, genre);</span>
+<span class="nc" id="L105"> theHub.addElement(s);</span>
+<span class="nc" id="L106"> System.out.println(&quot;New element list: &quot;);</span>
+<span class="nc" id="L107"> Iterator&lt;AudioElement&gt; it = theHub.elements();</span>
+<span class="nc bnc" id="L108" title="All 2 branches missed."> while (it.hasNext()) System.out.println(it.next().getTitle());</span>
+<span class="nc" id="L109"> System.out.println(&quot;Song created!&quot;);</span>
+<span class="nc" id="L110"> printAvailableCommands();</span>
+<span class="nc" id="L111"> choice = scan.nextLine();</span>
+<span class="nc" id="L112"> break;</span>
case 'a':
// add a new album
-<span class="nc" id="L112"> System.out.println(&quot;Enter a new album: &quot;);</span>
-<span class="nc" id="L113"> System.out.println(&quot;Album title: &quot;);</span>
-<span class="nc" id="L114"> String aTitle = scan.nextLine();</span>
-<span class="nc" id="L115"> System.out.println(&quot;Album artist: &quot;);</span>
-<span class="nc" id="L116"> String aArtist = scan.nextLine();</span>
-<span class="nc" id="L117"> System.out.println(&quot;Album length in seconds: &quot;);</span>
-<span class="nc" id="L118"> int aLength = Integer.parseInt(scan.nextLine());</span>
-<span class="nc" id="L119"> System.out.println(&quot;Album date as YYYY-DD-MM: &quot;);</span>
-<span class="nc" id="L120"> String aDate = scan.nextLine();</span>
-<span class="nc" id="L121"> Album a = new Album(aTitle, aArtist, aLength, aDate);</span>
-<span class="nc" id="L122"> theHub.addAlbum(a);</span>
-<span class="nc" id="L123"> System.out.println(&quot;New list of albums: &quot;);</span>
-<span class="nc" id="L124"> Iterator&lt;Album&gt; ita = theHub.albums();</span>
-<span class="nc bnc" id="L125" title="All 2 branches missed."> while (ita.hasNext()) System.out.println(ita.next().getTitle());</span>
-<span class="nc" id="L126"> System.out.println(&quot;Album created!&quot;);</span>
-<span class="nc" id="L127"> printAvailableCommands();</span>
-<span class="nc" id="L128"> choice = scan.nextLine();</span>
-<span class="nc" id="L129"> break;</span>
+<span class="nc" id="L115"> System.out.println(&quot;Enter a new album: &quot;);</span>
+<span class="nc" id="L116"> System.out.println(&quot;Album title: &quot;);</span>
+<span class="nc" id="L117"> String aTitle = scan.nextLine();</span>
+<span class="nc" id="L118"> System.out.println(&quot;Album artist: &quot;);</span>
+<span class="nc" id="L119"> String aArtist = scan.nextLine();</span>
+<span class="nc" id="L120"> System.out.println(&quot;Album length in seconds: &quot;);</span>
+<span class="nc" id="L121"> int aLength = Integer.parseInt(scan.nextLine());</span>
+<span class="nc" id="L122"> System.out.println(&quot;Album date as YYYY-DD-MM: &quot;);</span>
+<span class="nc" id="L123"> String aDate = scan.nextLine();</span>
+<span class="nc" id="L124"> Album a = new Album(aTitle, aArtist, aLength, aDate);</span>
+<span class="nc" id="L125"> theHub.addAlbum(a);</span>
+<span class="nc" id="L126"> System.out.println(&quot;New list of albums: &quot;);</span>
+<span class="nc" id="L127"> Iterator&lt;Album&gt; ita = theHub.albums();</span>
+<span class="nc bnc" id="L128" title="All 2 branches missed."> while (ita.hasNext()) System.out.println(ita.next().getTitle());</span>
+<span class="nc" id="L129"> System.out.println(&quot;Album created!&quot;);</span>
+<span class="nc" id="L130"> printAvailableCommands();</span>
+<span class="nc" id="L131"> choice = scan.nextLine();</span>
+<span class="nc" id="L132"> break;</span>
case '+':
//add a song to an album:
-<span class="nc" id="L132"> System.out.println(&quot;Add an existing song to an existing album&quot;);</span>
-<span class="nc" id="L133"> System.out.println(&quot;Type the name of the song you wish to add. Available songs: &quot;);</span>
-<span class="nc" id="L134"> Iterator&lt;AudioElement&gt; itae = theHub.elements();</span>
-<span class="nc bnc" id="L135" title="All 2 branches missed."> while (itae.hasNext()) {</span>
-<span class="nc" id="L136"> AudioElement ae = itae.next();</span>
-<span class="nc bnc" id="L137" title="All 2 branches missed."> if (ae instanceof Song) System.out.println(ae.getTitle());</span>
-<span class="nc" id="L138"> }</span>
-<span class="nc" id="L139"> String songTitle = scan.nextLine();</span>
+<span class="nc" id="L135"> System.out.println(&quot;Add an existing song to an existing album&quot;);</span>
+<span class="nc" id="L136"> System.out.println(&quot;Type the name of the song you wish to add. Available songs: &quot;);</span>
+<span class="nc" id="L137"> Iterator&lt;AudioElement&gt; itae = theHub.elements();</span>
+<span class="nc bnc" id="L138" title="All 2 branches missed."> while (itae.hasNext()) {</span>
+<span class="nc" id="L139"> AudioElement ae = itae.next();</span>
+<span class="nc bnc" id="L140" title="All 2 branches missed."> if (ae instanceof Song) System.out.println(ae.getTitle());</span>
+<span class="nc" id="L141"> }</span>
+<span class="nc" id="L142"> String songTitle = scan.nextLine();</span>
-<span class="nc" id="L141"> System.out.println(&quot;Type the name of the album you wish to enrich. Available albums: &quot;);</span>
-<span class="nc" id="L142"> Iterator&lt;Album&gt; ait = theHub.albums();</span>
-<span class="nc bnc" id="L143" title="All 2 branches missed."> while (ait.hasNext()) {</span>
-<span class="nc" id="L144"> Album al = ait.next();</span>
-<span class="nc" id="L145"> System.out.println(al.getTitle());</span>
-<span class="nc" id="L146"> }</span>
-<span class="nc" id="L147"> String titleAlbum = scan.nextLine();</span>
+<span class="nc" id="L144"> System.out.println(&quot;Type the name of the album you wish to enrich. Available albums: &quot;);</span>
+<span class="nc" id="L145"> Iterator&lt;Album&gt; ait = theHub.albums();</span>
+<span class="nc bnc" id="L146" title="All 2 branches missed."> while (ait.hasNext()) {</span>
+<span class="nc" id="L147"> Album al = ait.next();</span>
+<span class="nc" id="L148"> System.out.println(al.getTitle());</span>
+<span class="nc" id="L149"> }</span>
+<span class="nc" id="L150"> String titleAlbum = scan.nextLine();</span>
try {
-<span class="nc" id="L149"> theHub.addElementToAlbum(songTitle, titleAlbum);</span>
-<span class="nc" id="L150"> } catch (NoAlbumFoundException | NoElementFoundException ex) {</span>
-<span class="nc" id="L151"> System.out.println(ex.getMessage());</span>
-<span class="nc" id="L152"> }</span>
-<span class="nc" id="L153"> System.out.println(&quot;Song added to the album!&quot;);</span>
-<span class="nc" id="L154"> printAvailableCommands();</span>
-<span class="nc" id="L155"> choice = scan.nextLine();</span>
-<span class="nc" id="L156"> break;</span>
+<span class="nc" id="L152"> theHub.addElementToAlbum(songTitle, titleAlbum);</span>
+<span class="nc" id="L153"> } catch (NoAlbumFoundException | NoElementFoundException ex) {</span>
+<span class="nc" id="L154"> System.out.println(ex.getMessage());</span>
+<span class="nc" id="L155"> }</span>
+<span class="nc" id="L156"> System.out.println(&quot;Song added to the album!&quot;);</span>
+<span class="nc" id="L157"> printAvailableCommands();</span>
+<span class="nc" id="L158"> choice = scan.nextLine();</span>
+<span class="nc" id="L159"> break;</span>
case 'l':
// add a new audiobook
-<span class="nc" id="L159"> System.out.println(&quot;Enter a new audiobook: &quot;);</span>
-<span class="nc" id="L160"> System.out.println(&quot;AudioBook title: &quot;);</span>
-<span class="nc" id="L161"> String bTitle = scan.nextLine();</span>
-<span class="nc" id="L162"> System.out.println(&quot;AudioBook category (youth, novel, theater, documentary, speech)&quot;);</span>
-<span class="nc" id="L163"> String bCategory = scan.nextLine();</span>
-<span class="nc" id="L164"> System.out.println(&quot;AudioBook artist: &quot;);</span>
-<span class="nc" id="L165"> String bArtist = scan.nextLine();</span>
-<span class="nc" id="L166"> System.out.println(&quot;AudioBook length in seconds: &quot;);</span>
-<span class="nc" id="L167"> int bLength = Integer.parseInt(scan.nextLine());</span>
-<span class="nc" id="L168"> System.out.println(&quot;AudioBook content: &quot;);</span>
-<span class="nc" id="L169"> String bContent = scan.nextLine();</span>
-<span class="nc" id="L170"> System.out.println(&quot;AudioBook language (french, english, italian, spanish, german)&quot;);</span>
-<span class="nc" id="L171"> String bLanguage = scan.nextLine();</span>
-<span class="nc" id="L172"> AudioBook b = new AudioBook(bTitle, bArtist, bLength, bContent, bLanguage, bCategory);</span>
-<span class="nc" id="L173"> theHub.addElement(b);</span>
-<span class="nc" id="L174"> System.out.println(&quot;Audiobook created! New element list: &quot;);</span>
-<span class="nc" id="L175"> Iterator&lt;AudioElement&gt; itl = theHub.elements();</span>
-<span class="nc bnc" id="L176" title="All 2 branches missed."> while (itl.hasNext()) System.out.println(itl.next().getTitle());</span>
-<span class="nc" id="L177"> printAvailableCommands();</span>
-<span class="nc" id="L178"> choice = scan.nextLine();</span>
-<span class="nc" id="L179"> break;</span>
+<span class="nc" id="L162"> System.out.println(&quot;Enter a new audiobook: &quot;);</span>
+<span class="nc" id="L163"> System.out.println(&quot;AudioBook title: &quot;);</span>
+<span class="nc" id="L164"> String bTitle = scan.nextLine();</span>
+<span class="nc" id="L165"> System.out.println(&quot;AudioBook category (youth, novel, theater, documentary, speech)&quot;);</span>
+<span class="nc" id="L166"> String bCategory = scan.nextLine();</span>
+<span class="nc" id="L167"> System.out.println(&quot;AudioBook artist: &quot;);</span>
+<span class="nc" id="L168"> String bArtist = scan.nextLine();</span>
+<span class="nc" id="L169"> System.out.println(&quot;AudioBook length in seconds: &quot;);</span>
+<span class="nc" id="L170"> int bLength = Integer.parseInt(scan.nextLine());</span>
+<span class="nc" id="L171"> System.out.println(&quot;AudioBook content: &quot;);</span>
+<span class="nc" id="L172"> String bContent = scan.nextLine();</span>
+<span class="nc" id="L173"> System.out.println(&quot;AudioBook language (french, english, italian, spanish, german)&quot;);</span>
+<span class="nc" id="L174"> String bLanguage = scan.nextLine();</span>
+<span class="nc" id="L175"> AudioBook b = new AudioBook(bTitle, bArtist, bLength, bContent, bLanguage, bCategory);</span>
+<span class="nc" id="L176"> theHub.addElement(b);</span>
+<span class="nc" id="L177"> System.out.println(&quot;Audiobook created! New element list: &quot;);</span>
+<span class="nc" id="L178"> Iterator&lt;AudioElement&gt; itl = theHub.elements();</span>
+<span class="nc bnc" id="L179" title="All 2 branches missed."> while (itl.hasNext()) System.out.println(itl.next().getTitle());</span>
+<span class="nc" id="L180"> printAvailableCommands();</span>
+<span class="nc" id="L181"> choice = scan.nextLine();</span>
+<span class="nc" id="L182"> break;</span>
case 'p':
//create a new playlist from existing elements
-<span class="nc" id="L182"> System.out.println(&quot;Add an existing song or audiobook to a new playlist&quot;);</span>
-<span class="nc" id="L183"> System.out.println(&quot;Existing playlists:&quot;);</span>
-<span class="nc" id="L184"> Iterator&lt;PlayList&gt; itpl = theHub.playlists();</span>
-<span class="nc bnc" id="L185" title="All 2 branches missed."> while (itpl.hasNext()) {</span>
-<span class="nc" id="L186"> PlayList pl = itpl.next();</span>
-<span class="nc" id="L187"> System.out.println(pl.getTitle());</span>
-<span class="nc" id="L188"> }</span>
-<span class="nc" id="L189"> System.out.println(&quot;Type the name of the playlist you wish to create:&quot;);</span>
-<span class="nc" id="L190"> String playListTitle = scan.nextLine();</span>
-<span class="nc" id="L191"> PlayList pl = new PlayList(playListTitle);</span>
-<span class="nc" id="L192"> theHub.addPlaylist(pl);</span>
-<span class="nc" id="L193"> System.out.println(&quot;Available elements: &quot;);</span>
+<span class="nc" id="L185"> System.out.println(&quot;Add an existing song or audiobook to a new playlist&quot;);</span>
+<span class="nc" id="L186"> System.out.println(&quot;Existing playlists:&quot;);</span>
+<span class="nc" id="L187"> Iterator&lt;PlayList&gt; itpl = theHub.playlists();</span>
+<span class="nc bnc" id="L188" title="All 2 branches missed."> while (itpl.hasNext()) {</span>
+<span class="nc" id="L189"> PlayList pl = itpl.next();</span>
+<span class="nc" id="L190"> System.out.println(pl.getTitle());</span>
+<span class="nc" id="L191"> }</span>
+<span class="nc" id="L192"> System.out.println(&quot;Type the name of the playlist you wish to create:&quot;);</span>
+<span class="nc" id="L193"> String playListTitle = scan.nextLine();</span>
+<span class="nc" id="L194"> PlayList pl = new PlayList(playListTitle);</span>
+<span class="nc" id="L195"> theHub.addPlaylist(pl);</span>
+<span class="nc" id="L196"> System.out.println(&quot;Available elements: &quot;);</span>
-<span class="nc" id="L195"> Iterator&lt;AudioElement&gt; itael = theHub.elements();</span>
-<span class="nc bnc" id="L196" title="All 2 branches missed."> while (itael.hasNext()) {</span>
-<span class="nc" id="L197"> AudioElement ae = itael.next();</span>
-<span class="nc" id="L198"> System.out.println(ae.getTitle());</span>
-<span class="nc" id="L199"> }</span>
-<span class="nc bnc" id="L200" title="All 2 branches missed."> while (choice.charAt(0) != 'n') {</span>
-<span class="nc" id="L201"> System.out.println(&quot;Type the name of the audio element you wish to add or 'n' to exit:&quot;);</span>
-<span class="nc" id="L202"> String elementTitle = scan.nextLine();</span>
+<span class="nc" id="L198"> Iterator&lt;AudioElement&gt; itael = theHub.elements();</span>
+<span class="nc bnc" id="L199" title="All 2 branches missed."> while (itael.hasNext()) {</span>
+<span class="nc" id="L200"> AudioElement ae = itael.next();</span>
+<span class="nc" id="L201"> System.out.println(ae.getTitle());</span>
+<span class="nc" id="L202"> }</span>
+<span class="nc bnc" id="L203" title="All 2 branches missed."> while (choice.charAt(0) != 'n') {</span>
+<span class="nc" id="L204"> System.out.println(&quot;Type the name of the audio element you wish to add or 'n' to exit:&quot;);</span>
+<span class="nc" id="L205"> String elementTitle = scan.nextLine();</span>
try {
-<span class="nc" id="L204"> theHub.addElementToPlayList(elementTitle, playListTitle);</span>
-<span class="nc" id="L205"> } catch (NoPlayListFoundException | NoElementFoundException ex) {</span>
-<span class="nc" id="L206"> System.out.println(ex.getMessage());</span>
-<span class="nc" id="L207"> }</span>
+<span class="nc" id="L207"> theHub.addElementToPlayList(elementTitle, playListTitle);</span>
+<span class="nc" id="L208"> } catch (NoPlayListFoundException | NoElementFoundException ex) {</span>
+<span class="nc" id="L209"> System.out.println(ex.getMessage());</span>
+<span class="nc" id="L210"> }</span>
-<span class="nc" id="L209"> System.out.println(&quot;Type y to add a new one, n to end&quot;);</span>
-<span class="nc" id="L210"> choice = scan.nextLine();</span>
-<span class="nc" id="L211"> }</span>
-<span class="nc" id="L212"> System.out.println(&quot;Playlist created!&quot;);</span>
-<span class="nc" id="L213"> printAvailableCommands();</span>
-<span class="nc" id="L214"> choice = scan.nextLine();</span>
-<span class="nc" id="L215"> break;</span>
+<span class="nc" id="L212"> System.out.println(&quot;Type y to add a new one, n to end&quot;);</span>
+<span class="nc" id="L213"> choice = scan.nextLine();</span>
+<span class="nc" id="L214"> }</span>
+<span class="nc" id="L215"> System.out.println(&quot;Playlist created!&quot;);</span>
+<span class="nc" id="L216"> printAvailableCommands();</span>
+<span class="nc" id="L217"> choice = scan.nextLine();</span>
+<span class="nc" id="L218"> break;</span>
case '-':
//delete a playlist
-<span class="nc" id="L218"> System.out.println(&quot;Delete an existing playlist. Available playlists:&quot;);</span>
-<span class="nc" id="L219"> Iterator&lt;PlayList&gt; itp = theHub.playlists();</span>
-<span class="nc bnc" id="L220" title="All 2 branches missed."> while (itp.hasNext()) {</span>
-<span class="nc" id="L221"> PlayList p = itp.next();</span>
-<span class="nc" id="L222"> System.out.println(p.getTitle());</span>
-<span class="nc" id="L223"> }</span>
-<span class="nc" id="L224"> String plTitle = scan.nextLine();</span>
+<span class="nc" id="L221"> System.out.println(&quot;Delete an existing playlist. Available playlists:&quot;);</span>
+<span class="nc" id="L222"> Iterator&lt;PlayList&gt; itp = theHub.playlists();</span>
+<span class="nc bnc" id="L223" title="All 2 branches missed."> while (itp.hasNext()) {</span>
+<span class="nc" id="L224"> PlayList p = itp.next();</span>
+<span class="nc" id="L225"> System.out.println(p.getTitle());</span>
+<span class="nc" id="L226"> }</span>
+<span class="nc" id="L227"> String plTitle = scan.nextLine();</span>
try {
-<span class="nc" id="L226"> theHub.deletePlayList(plTitle);</span>
-<span class="nc" id="L227"> } catch (NoPlayListFoundException ex) {</span>
-<span class="nc" id="L228"> System.out.println(ex.getMessage());</span>
-<span class="nc" id="L229"> }</span>
-<span class="nc" id="L230"> System.out.println(&quot;Playlist deleted!&quot;);</span>
-<span class="nc" id="L231"> printAvailableCommands();</span>
-<span class="nc" id="L232"> choice = scan.nextLine();</span>
-<span class="nc" id="L233"> break;</span>
+<span class="nc" id="L229"> theHub.deletePlayList(plTitle);</span>
+<span class="nc" id="L230"> } catch (NoPlayListFoundException ex) {</span>
+<span class="nc" id="L231"> System.out.println(ex.getMessage());</span>
+<span class="nc" id="L232"> }</span>
+<span class="nc" id="L233"> System.out.println(&quot;Playlist deleted!&quot;);</span>
+<span class="nc" id="L234"> printAvailableCommands();</span>
+<span class="nc" id="L235"> choice = scan.nextLine();</span>
+<span class="nc" id="L236"> break;</span>
case 's':
//save elements, albums, playlists
-<span class="nc" id="L236"> theHub.saveElements();</span>
-<span class="nc" id="L237"> theHub.saveAlbums();</span>
-<span class="nc" id="L238"> theHub.savePlayLists();</span>
-<span class="nc" id="L239"> System.out.println(&quot;Elements, albums and playlists saved!&quot;);</span>
-<span class="nc" id="L240"> printAvailableCommands();</span>
-<span class="nc" id="L241"> choice = scan.nextLine();</span>
-<span class="nc" id="L242"> break;</span>
+<span class="nc" id="L239"> theHub.saveElements();</span>
+<span class="nc" id="L240"> theHub.saveAlbums();</span>
+<span class="nc" id="L241"> theHub.savePlayLists();</span>
+<span class="nc" id="L242"> System.out.println(&quot;Elements, albums and playlists saved!&quot;);</span>
+<span class="nc" id="L243"> printAvailableCommands();</span>
+<span class="nc" id="L244"> choice = scan.nextLine();</span>
+<span class="nc" id="L245"> break;</span>
+ case 'o':
+ //consult the app logs
+<span class="nc" id="L248"> LogHandler.read();</span>
+<span class="nc" id="L249"> System.out.println(&quot;Type h for available commands&quot;);</span>
+<span class="nc" id="L250"> choice = scan.nextLine();</span>
+<span class="nc" id="L251"> break;</span>
default:
-<span class="nc" id="L245"> break;</span>
+<span class="nc" id="L254"> break;</span>
}
}
-<span class="nc" id="L248"> scan.close();</span>
-<span class="nc" id="L249"> }</span>
+<span class="nc" id="L257"> scan.close();</span>
+<span class="nc" id="L258"> }</span>
private static void printAvailableCommands() {
-<span class="nc" id="L252"> System.out.println(&quot;t: display the album titles, ordered by date&quot;);</span>
-<span class="nc" id="L253"> System.out.println(&quot;g: display songs of an album, ordered by genre&quot;);</span>
-<span class="nc" id="L254"> System.out.println(&quot;d: display songs of an album&quot;);</span>
-<span class="nc" id="L255"> System.out.println(&quot;u: display audiobooks ordered by author&quot;);</span>
-<span class="nc" id="L256"> System.out.println(&quot;c: add a new song&quot;);</span>
-<span class="nc" id="L257"> System.out.println(&quot;a: add a new album&quot;);</span>
-<span class="nc" id="L258"> System.out.println(&quot;+: add a song to an album&quot;);</span>
-<span class="nc" id="L259"> System.out.println(&quot;l: add a new audiobook&quot;);</span>
-<span class="nc" id="L260"> System.out.println(&quot;p: create a new playlist from existing songs and audio books&quot;);</span>
-<span class="nc" id="L261"> System.out.println(&quot;-: delete an existing playlist&quot;);</span>
-<span class="nc" id="L262"> System.out.println(&quot;s: save elements, albums, playlists&quot;);</span>
-<span class="nc" id="L263"> System.out.println(&quot;q: quit program&quot;);</span>
-<span class="nc" id="L264"> }</span>
+<span class="nc" id="L261"> System.out.println(&quot;t: display the album titles, ordered by date&quot;);</span>
+<span class="nc" id="L262"> System.out.println(&quot;g: display songs of an album, ordered by genre&quot;);</span>
+<span class="nc" id="L263"> System.out.println(&quot;d: display songs of an album&quot;);</span>
+<span class="nc" id="L264"> System.out.println(&quot;u: display audiobooks ordered by author&quot;);</span>
+<span class="nc" id="L265"> System.out.println(&quot;c: add a new song&quot;);</span>
+<span class="nc" id="L266"> System.out.println(&quot;a: add a new album&quot;);</span>
+<span class="nc" id="L267"> System.out.println(&quot;+: add a song to an album&quot;);</span>
+<span class="nc" id="L268"> System.out.println(&quot;l: add a new audiobook&quot;);</span>
+<span class="nc" id="L269"> System.out.println(&quot;p: create a new playlist from existing songs and audio books&quot;);</span>
+<span class="nc" id="L270"> System.out.println(&quot;-: delete an existing playlist&quot;);</span>
+<span class="nc" id="L271"> System.out.println(&quot;s: save elements, albums, playlists&quot;);</span>
+<span class="nc" id="L272"> System.out.println(&quot;o: consult the app logs&quot;);</span>
+<span class="nc" id="L273"> System.out.println(&quot;q: quit program&quot;);</span>
+<span class="nc" id="L274"> }</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