From 49196ae84aea338dbc6cd10f4d135e4b717cdd1f Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Mon, 28 Jun 2021 23:38:36 +0200 Subject: Latest package, javadoc and jacoco --- target/site/jacoco/musichub.main/Main.html | 2 +- target/site/jacoco/musichub.main/Main.java.html | 429 ++++++++++++--------- target/site/jacoco/musichub.main/index.html | 2 +- target/site/jacoco/musichub.main/index.source.html | 2 +- 4 files changed, 239 insertions(+), 196 deletions(-) (limited to 'target/site/jacoco/musichub.main') diff --git a/target/site/jacoco/musichub.main/Main.html b/target/site/jacoco/musichub.main/Main.html index 3666c2b..f24445f 100644 --- a/target/site/jacoco/musichub.main/Main.html +++ b/target/site/jacoco/musichub.main/Main.html @@ -1 +1 @@ -Main

Main

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total625 of 6250 %42 of 420 %313121521533
main(String[])5790 %420 %292919919911
printAvailableCommands()430 %n/a11151511
Main()0 %n/a111111
\ No newline at end of file +Main

Main

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethods
Total722 of 7220 %43 of 430 %323225125133
main(String[])6730 %430 %303023423411
printAvailableCommands()460 %n/a11161611
Main()0 %n/a111111
\ No newline at end of file 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; if (choice.length() == 0) System.exit(0); while (!choice.equals("")) { //if the user puts nothing, quit the loop/system - switch (choice.charAt(0)) { + switch (choice.charAt(0)) { case 'q': //added the option directly in the switch instead of the loop System.exit(0); case 'h': @@ -54,240 +54,283 @@ import static musichub.util.Policy.showTerm; List<Song> songs = theHub.getAlbumSongsSortedByGenre(albumTitle); System.out.println(songs); } catch (NoAlbumFoundException ex) { - System.out.println("No album found with the requested title " + ex.getMessage()); - } - printAvailableCommands(); - choice = scan.nextLine(); - break; + LogHandler.write("No album found with the requested title", "WARNING"); + System.out.println("No album found with the requested title " + ex.getMessage()); + } + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'd': //songs of an album - System.out.println("Songs of an album will be displayed; enter the album name, available albums are:"); - System.out.println(theHub.getAlbumsTitlesSortedByDate()); + System.out.println("Songs of an album will be displayed; enter the album name, available albums are:"); + System.out.println(theHub.getAlbumsTitlesSortedByDate()); - albumTitle = scan.nextLine(); + albumTitle = scan.nextLine(); try { - List<AudioElement> songs = theHub.getAlbumSongs(albumTitle); - System.out.println(theHub.getAlbumSongs(albumTitle)); - String song = scan.nextLine(); - theHub.getAudioElement(songs, song); - } catch (NoAlbumFoundException ex) { - System.out.println("No album found with the requested title " + ex.getMessage()); - } - printAvailableCommands(); - choice = scan.nextLine(); - break; + List<AudioElement> songs = theHub.getAlbumSongs(albumTitle); + System.out.println(theHub.getAlbumSongs(albumTitle)); + String song = scan.nextLine(); + theHub.getAudioElement(songs, song); + } catch (NoAlbumFoundException ex) { + LogHandler.write("No album found with the requested title", "WARNING"); + System.out.println("No album found with the requested title " + ex.getMessage()); + } + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'u': //audiobooks ordered by author - System.out.println(theHub.getAudiobooksTitlesSortedByAuthor()); - printAvailableCommands(); - choice = scan.nextLine(); - break; + System.out.println(theHub.getAudiobooksTitlesSortedByAuthor()); + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'c': // add a new song - System.out.println("Enter a new song: "); - System.out.println("Song title: "); - String title = scan.nextLine(); - System.out.println("Song genre (jazz, classic, hiphop, rock, pop, rap):"); - String genre = scan.nextLine(); - System.out.println("Song artist: "); - String artist = scan.nextLine(); - System.out.println("Song length in seconds: "); - int length = Integer.parseInt(scan.nextLine()); + System.out.println("Enter a new song: "); + System.out.println("Song title: "); + String title = scan.nextLine(); + System.out.println("Song genre (jazz, classic, hiphop, rock, pop, rap):"); + String genre = scan.nextLine(); + System.out.println("Song artist: "); + String artist = scan.nextLine(); - System.out.println("Song content: "); - String content = scan.nextLine(); - if (!isPathValid(content)) { - String logMsg = "The music file was not found with the path you've provided or the extension is not .wav"; - LogHandler.write(logMsg, "WARNING"); //write a line in the log file - System.out.println(logMsg + "\nType h for available commands"); - choice = scan.nextLine(); - break; + int length; + try { + System.out.println("Song length in seconds: "); + length = Integer.parseInt(scan.nextLine()); + } catch (NumberFormatException ex) { + String logMsg = "You've not provided a number for the length."; + LogHandler.write(logMsg, "ERROR"); //write a line in the log file + System.err.println(logMsg); + System.out.println("Type h for available commands"); + choice = scan.nextLine(); + break; + } + + System.out.println("Song content: "); + String content = scan.nextLine(); + if (!isPathValid(content)) { + String logMsg = "The music file cannot be found with the path you've provided or the extension is not .wav"; + LogHandler.write(logMsg, "ERROR"); //write a line in the log file + System.err.println(logMsg); + System.out.println("Type h for available commands"); + choice = scan.nextLine(); + break; } - Song s = new Song(title, artist, length, content, genre); - theHub.addElement(s); - System.out.println("New element list: "); - Iterator<AudioElement> it = theHub.elements(); - while (it.hasNext()) System.out.println(it.next().getTitle()); - System.out.println("Song created!"); - printAvailableCommands(); - choice = scan.nextLine(); - break; + Song s = new Song(title, artist, length, content, genre); + theHub.addElement(s); + System.out.println("New element list: "); + Iterator<AudioElement> it = theHub.elements(); + while (it.hasNext()) System.out.println(it.next().getTitle()); + LogHandler.write("Song successfully created", "INFO"); + System.out.println("Song created!"); + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'a': // add a new album - System.out.println("Enter a new album: "); - System.out.println("Album title: "); - String aTitle = scan.nextLine(); - System.out.println("Album artist: "); - String aArtist = scan.nextLine(); - System.out.println("Album length in seconds: "); - int aLength = Integer.parseInt(scan.nextLine()); - System.out.println("Album date as YYYY-DD-MM: "); - String aDate = scan.nextLine(); - Album a = new Album(aTitle, aArtist, aLength, aDate); - theHub.addAlbum(a); - System.out.println("New list of albums: "); - Iterator<Album> ita = theHub.albums(); - while (ita.hasNext()) System.out.println(ita.next().getTitle()); - System.out.println("Album created!"); - printAvailableCommands(); - choice = scan.nextLine(); - break; + System.out.println("Enter a new album: "); + System.out.println("Album title: "); + String aTitle = scan.nextLine(); + System.out.println("Album artist: "); + String aArtist = scan.nextLine(); + System.out.println("Album length in seconds: "); + int aLength = Integer.parseInt(scan.nextLine()); + System.out.println("Album date as YYYY-DD-MM: "); + String aDate = scan.nextLine(); + Album a = new Album(aTitle, aArtist, aLength, aDate); + theHub.addAlbum(a); + System.out.println("New list of albums: "); + Iterator<Album> ita = theHub.albums(); + while (ita.hasNext()) System.out.println(ita.next().getTitle()); + LogHandler.write("Album successfully created", "INFO"); + System.out.println("Album created!"); + printAvailableCommands(); + choice = scan.nextLine(); + break; case '+': //add a song to an album: - System.out.println("Add an existing song to an existing album"); - System.out.println("Type the name of the song you wish to add. Available songs: "); - Iterator<AudioElement> itae = theHub.elements(); - while (itae.hasNext()) { - AudioElement ae = itae.next(); - if (ae instanceof Song) System.out.println(ae.getTitle()); - } - String songTitle = scan.nextLine(); + System.out.println("Add an existing song to an existing album"); + System.out.println("Type the name of the song you wish to add. Available songs: "); + Iterator<AudioElement> itae = theHub.elements(); + while (itae.hasNext()) { + AudioElement ae = itae.next(); + if (ae instanceof Song) System.out.println(ae.getTitle()); + } + String songTitle = scan.nextLine(); - System.out.println("Type the name of the album you wish to enrich. Available albums: "); - Iterator<Album> ait = theHub.albums(); - while (ait.hasNext()) { - Album al = ait.next(); - System.out.println(al.getTitle()); - } - String titleAlbum = scan.nextLine(); + System.out.println("Type the name of the album you wish to enrich. Available albums: "); + Iterator<Album> ait = theHub.albums(); + while (ait.hasNext()) { + Album al = ait.next(); + System.out.println(al.getTitle()); + } + String titleAlbum = scan.nextLine(); try { - theHub.addElementToAlbum(songTitle, titleAlbum); - } catch (NoAlbumFoundException | NoElementFoundException ex) { - System.out.println(ex.getMessage()); - } - System.out.println("Song added to the album!"); - printAvailableCommands(); - choice = scan.nextLine(); - break; + theHub.addElementToAlbum(songTitle, titleAlbum); + } catch (NoAlbumFoundException | NoElementFoundException ex) { + System.out.println(ex.getMessage()); + } + LogHandler.write("Song successfully added to the album", "INFO"); + System.out.println("Song added to the album!"); + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'l': // add a new audiobook - System.out.println("Enter a new audiobook: "); - System.out.println("AudioBook title: "); - String bTitle = scan.nextLine(); - System.out.println("AudioBook category (youth, novel, theater, documentary, speech)"); - String bCategory = scan.nextLine(); - System.out.println("AudioBook artist: "); - String bArtist = scan.nextLine(); - System.out.println("AudioBook length in seconds: "); - int bLength = Integer.parseInt(scan.nextLine()); - System.out.println("AudioBook content: "); - String bContent = scan.nextLine(); - System.out.println("AudioBook language (french, english, italian, spanish, german)"); - String bLanguage = scan.nextLine(); - AudioBook b = new AudioBook(bTitle, bArtist, bLength, bContent, bLanguage, bCategory); - theHub.addElement(b); - System.out.println("Audiobook created! New element list: "); - Iterator<AudioElement> itl = theHub.elements(); - while (itl.hasNext()) System.out.println(itl.next().getTitle()); - printAvailableCommands(); - choice = scan.nextLine(); - break; + System.out.println("Enter a new audiobook: "); + System.out.println("AudioBook title: "); + String bTitle = scan.nextLine(); + System.out.println("AudioBook category (youth, novel, theater, documentary, speech)"); + String bCategory = scan.nextLine(); + System.out.println("AudioBook artist: "); + String bArtist = scan.nextLine(); + System.out.println("AudioBook length in seconds: "); + int bLength = Integer.parseInt(scan.nextLine()); + System.out.println("AudioBook content: "); + String bContent = scan.nextLine(); + System.out.println("AudioBook language (french, english, italian, spanish, german)"); + String bLanguage = scan.nextLine(); + AudioBook b = new AudioBook(bTitle, bArtist, bLength, bContent, bLanguage, bCategory); + theHub.addElement(b); + LogHandler.write("Audiobook successfully created", "INFO"); + System.out.println("Audiobook created! New element list: "); + Iterator<AudioElement> itl = theHub.elements(); + while (itl.hasNext()) System.out.println(itl.next().getTitle()); + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'p': //create a new playlist from existing elements - System.out.println("Add an existing song or audiobook to a new playlist"); - System.out.println("Existing playlists:"); - Iterator<PlayList> itpl = theHub.playlists(); - while (itpl.hasNext()) { - PlayList pl = itpl.next(); - System.out.println(pl.getTitle()); - } - System.out.println("Type the name of the playlist you wish to create:"); - String playListTitle = scan.nextLine(); - PlayList pl = new PlayList(playListTitle); - theHub.addPlaylist(pl); - System.out.println("Available elements: "); + System.out.println("Add an existing song or audiobook to a new playlist"); + System.out.println("Existing playlists:"); + Iterator<PlayList> itpl = theHub.playlists(); + while (itpl.hasNext()) { + PlayList pl = itpl.next(); + System.out.println(pl.getTitle()); + } + System.out.println("Type the name of the playlist you wish to create:"); + String playListTitle = scan.nextLine(); + PlayList pl = new PlayList(playListTitle); + theHub.addPlaylist(pl); + System.out.println("Available elements: "); - Iterator<AudioElement> itael = theHub.elements(); - while (itael.hasNext()) { - AudioElement ae = itael.next(); - System.out.println(ae.getTitle()); - } - while (choice.charAt(0) != 'n') { - System.out.println("Type the name of the audio element you wish to add or 'n' to exit:"); - String elementTitle = scan.nextLine(); + Iterator<AudioElement> itael = theHub.elements(); + while (itael.hasNext()) { + AudioElement ae = itael.next(); + System.out.println(ae.getTitle()); + } + while (choice.charAt(0) != 'n') { + System.out.println("Type the name of the audio element you wish to add or 'n' to exit:"); + String elementTitle = scan.nextLine(); try { - theHub.addElementToPlayList(elementTitle, playListTitle); - } catch (NoPlayListFoundException | NoElementFoundException ex) { - System.out.println(ex.getMessage()); - } + theHub.addElementToPlayList(elementTitle, playListTitle); + } catch (NoPlayListFoundException | NoElementFoundException ex) { + System.out.println(ex.getMessage()); + } - System.out.println("Type y to add a new one, n to end"); - choice = scan.nextLine(); - } - System.out.println("Playlist created!"); - printAvailableCommands(); - choice = scan.nextLine(); - break; + System.out.println("Type y to add a new one, n to end"); + choice = scan.nextLine(); + } + LogHandler.write("Playlist successfully created", "INFO"); + System.out.println("Playlist created!"); + printAvailableCommands(); + choice = scan.nextLine(); + break; case '-': //delete a playlist - System.out.println("Delete an existing playlist. Available playlists:"); - Iterator<PlayList> itp = theHub.playlists(); - while (itp.hasNext()) { - PlayList p = itp.next(); - System.out.println(p.getTitle()); - } - String plTitle = scan.nextLine(); + System.out.println("Delete an existing playlist. Available playlists:"); + Iterator<PlayList> itp = theHub.playlists(); + while (itp.hasNext()) { + PlayList p = itp.next(); + System.out.println(p.getTitle()); + } + String plTitle = scan.nextLine(); try { - theHub.deletePlayList(plTitle); - } catch (NoPlayListFoundException ex) { - System.out.println(ex.getMessage()); - } - System.out.println("Playlist deleted!"); - printAvailableCommands(); - choice = scan.nextLine(); - break; + theHub.deletePlayList(plTitle); + } catch (NoPlayListFoundException ex) { + System.out.println(ex.getMessage()); + } + LogHandler.write("Playlist successfully deleted", "INFO"); + System.out.println("Playlist deleted!"); + printAvailableCommands(); + choice = scan.nextLine(); + break; case 's': //save elements, albums, playlists - theHub.saveElements(); - theHub.saveAlbums(); - theHub.savePlayLists(); - System.out.println("Elements, albums and playlists saved!"); - printAvailableCommands(); - choice = scan.nextLine(); - break; + theHub.saveElements(); + theHub.saveAlbums(); + theHub.savePlayLists(); + LogHandler.write("Elements, albums and playlists successfully saved", "INFO"); + System.out.println("Elements, albums and playlists saved!"); + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'r': //search a music try { - theHub.searchAudioElement(); + theHub.searchAudioElement(); } - catch (NoElementFoundException e){ - System.err.println(e.getMessage()); + catch (NoElementFoundException e){ + System.err.println(e.getMessage()); } - catch (java.io.FileNotFoundException e){ - System.err.println(e.getMessage()+" Please create a file with the extension .wav inside the song folder at root of the app"); - } - printAvailableCommands(); + catch (java.io.FileNotFoundException e){ + LogHandler.write("Please create a file with the extension .wav inside the song folder at root of the app", "ERROR"); + System.err.println(e.getMessage() + " Please create a file with the extension .wav inside the song folder at root of the app"); + } + printAvailableCommands(); + choice = scan.nextLine(); + break; case 'o': //consult the app logs - LogHandler.read(); - System.out.println("Type h for available commands"); - choice = scan.nextLine(); - break; + LogHandler.read(); + System.out.println("Type h for available commands"); + choice = scan.nextLine(); + break; + case 'm': + //songs of a playlist + System.out.println("Songs of a playlist will be displayed; enter the playlist name, available playlists are:"); + System.out.println(theHub.getPlayListsTitles()); + + playListTitle = scan.nextLine(); + try { + List<AudioElement> songs = theHub.getPlayListSongs(playListTitle); + System.out.println(theHub.getPlayListSongs(playListTitle)); + String song = scan.nextLine(); + theHub.getAudioElement(songs, song); + } catch (NoPlayListFoundException ex) { + LogHandler.write("No playlist found with the requested title", "WARNING"); + System.out.println("No playlist found with the requested title " + ex.getMessage()); + } + printAvailableCommands(); + choice = scan.nextLine(); + break; default: - break; + break; } } - scan.close(); - } + scan.close(); + } private static void printAvailableCommands() { - System.out.println("t: display the album titles, ordered by date"); - System.out.println("g: display songs of an album, ordered by genre"); - System.out.println("d: display songs of an album"); - System.out.println("u: display audiobooks ordered by author"); - System.out.println("r: search audio elements"); - System.out.println("c: add a new song"); - System.out.println("a: add a new album"); - System.out.println("+: add a song to an album"); - System.out.println("l: add a new audiobook"); - System.out.println("p: create a new playlist from existing songs and audio books"); - System.out.println("-: delete an existing playlist"); - System.out.println("s: save elements, albums, playlists"); - System.out.println("o: consult the app logs"); - System.out.println("q: quit program"); - } + System.out.println("t: display the album titles, ordered by date"); + System.out.println("g: display songs of an album, ordered by genre"); + System.out.println("d: display songs of an album"); + System.out.println("u: display audiobooks ordered by author"); + System.out.println("r: search audio elements"); + System.out.println("c: add a new song"); + System.out.println("a: add a new album"); + System.out.println("+: add a song to an album"); + System.out.println("l: add a new audiobook"); + System.out.println("p: create a new playlist from existing songs and audio books"); + System.out.println("m: display songs of a playlist"); + System.out.println("-: delete an existing playlist"); + System.out.println("s: save elements, albums, playlists"); + System.out.println("o: consult the app logs"); + System.out.println("q: quit program"); + } } \ No newline at end of file diff --git a/target/site/jacoco/musichub.main/index.html b/target/site/jacoco/musichub.main/index.html index cd2b4c7..9101830 100644 --- a/target/site/jacoco/musichub.main/index.html +++ b/target/site/jacoco/musichub.main/index.html @@ -1 +1 @@ -musichub.main

musichub.main

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total625 of 6250 %42 of 420 %31312152153311
Main6250 %420 %31312152153311
\ No newline at end of file +musichub.main

musichub.main

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total722 of 7220 %43 of 430 %32322512513311
Main7220 %430 %32322512513311
\ No newline at end of file diff --git a/target/site/jacoco/musichub.main/index.source.html b/target/site/jacoco/musichub.main/index.source.html index 60b6575..a2635d9 100644 --- a/target/site/jacoco/musichub.main/index.source.html +++ b/target/site/jacoco/musichub.main/index.source.html @@ -1 +1 @@ -musichub.main

musichub.main

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total625 of 6250 %42 of 420 %31312152153311
Main.java6250 %420 %31312152153311
\ No newline at end of file +musichub.main

musichub.main

ElementMissed InstructionsCov.Missed BranchesCov.MissedCxtyMissedLinesMissedMethodsMissedClasses
Total722 of 7220 %43 of 430 %32322512513311
Main.java7220 %430 %32322512513311
\ No newline at end of file -- cgit v1.2.3