aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Playlist.java13
-rw-r--r--albumsbin673 -> 962 bytes
-rw-r--r--audiobooksbin297 -> 670 bytes
-rw-r--r--jMusicHub.java68
-rw-r--r--playlistsbin968 -> 1140 bytes
-rwxr-xr-xrun4
-rw-r--r--songsbin379 -> 1474 bytes
7 files changed, 72 insertions, 13 deletions
diff --git a/Playlist.java b/Playlist.java
index 990aa26..8374c77 100644
--- a/Playlist.java
+++ b/Playlist.java
@@ -17,8 +17,17 @@ public class Playlist implements Serializable {
public int getId(){return id;}
public String getName(){return name.toUpperCase();} //using toUpperCase method because the way I sort by name sort he upper case then the lower case, which is inconvenient.
- public ArrayList<Song> getSongs(){return songs;}
- public ArrayList<AudioBook> getAudioBooks(){return audiobooks;}
+ public void getSongs(){
+ for ( Song s : songs ){
+ System.out.println(s);
+ }
+ }
+ public void getAudioBooks(){
+ for (AudioBook b : audiobooks ){
+ System.out.println(b);
+ }
+
+ }
public void setId(int id){this.id=id;}
public void setName(){this.name=name;}
diff --git a/albums b/albums
index e72f50b..7fd7df7 100644
--- a/albums
+++ b/albums
Binary files differ
diff --git a/audiobooks b/audiobooks
index da41cf0..1e73597 100644
--- a/audiobooks
+++ b/audiobooks
Binary files differ
diff --git a/jMusicHub.java b/jMusicHub.java
index 715f85f..985a6a2 100644
--- a/jMusicHub.java
+++ b/jMusicHub.java
@@ -309,6 +309,7 @@ public class jMusicHub {
for (Playlist p : playlists ){
System.out.println(p);
}
+
break;
}
@@ -363,7 +364,12 @@ public class jMusicHub {
in.close();
file.close();
- listById("songs");
+// listById("songs");
+ int songCount=0;
+ for ( Song s : songs ){
+ songCount+=1;
+ }
+ System.out.println("Extracted songs : "+songCount);
return new ArrayList<Song>(songs);
case "audiobooks" :
@@ -373,7 +379,12 @@ public class jMusicHub {
in.close();
file.close();
- listById("audiobooks");
+// listById("audiobooks");
+ int bookCount=0;
+ for ( AudioBook b : audiobooks ){
+ bookCount+=1;
+ }
+ System.out.println("Exctracted audiobooks : "+bookCount);
return new ArrayList<AudioBook>(audiobooks);
case "albums" :
@@ -383,7 +394,12 @@ public class jMusicHub {
in.close();
file.close();
- listById("albums");
+// listById("albums");
+ int albumCount=0;
+ for ( Album a : albums ){
+ albumCount+=1;
+ }
+ System.out.println("Extracted albums : "+albumCount);
return new ArrayList<Album>(albums);
case "playlists" :
@@ -393,7 +409,12 @@ public class jMusicHub {
in.close();
file.close();
- listById("playlists");
+// listById("playlists");
+ int playlistCount=0;
+ for ( Playlist p : playlists ){
+ playlistCount+=1;
+ }
+ System.out.println("Extracted playlists : "+playlistCount);
return new ArrayList<Playlist>(playlists);
default :
@@ -457,6 +478,23 @@ public class jMusicHub {
return playlists;
}
+ public static void contentOfPlaylist(ArrayList<Playlist> playlists){
+ Scanner scan = new Scanner(System.in);
+ listById("playlists");
+ System.out.println("\nWhich one do you want to see ?");
+ System.out.printf("Playlist's ID : ");
+ int playlistId = scan.nextInt();
+ String trash = scan.nextLine();
+ for ( Playlist p : playlists ){
+ if ( playlistId == p.getId() ){
+ System.out.println("\nSongs : \n");
+ p.getSongs();
+ System.out.println("\nAudioBooks : \n");
+ p.getAudioBooks();
+ }
+ }
+ }
+
public jMusicHub() {
System.out.println("Welcome to the jMusicHub !\n");
@@ -464,7 +502,7 @@ public class jMusicHub {
Scanner scan = new Scanner(System.in);
String userInput; //Used to get the user's inputs.
- System.out.println("Extraction beginning...");
+ System.out.println("Extraction beginning...\n");
@SuppressWarnings("unchecked")
ArrayList<Song> songs = extract("songs");
@SuppressWarnings("unchecked")
@@ -477,12 +515,13 @@ public class jMusicHub {
System.out.println("\nExtraction done.");
do {
- System.out.println("What do you want to do? [h for help]");
+ System.out.println("\nWhat do you want to do? [h for help]");
userInput = scan.nextLine();
+ System.out.println("");
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\n\nh: print this help screen\nq: quit the program\n");
+ System.out.printf("c: add a new song\na: add a new album\n+: add an existing song to an album\nl: add a new audiobook\n\np: create a new playlist from existing songs and audiobooks\n-: delete a playlist\n\ns: save playlists, albums, songs and audiobooks into the concerned files\n\nS: List all your saved songs\nB: List all your saved audiobooks\nA: List all your saved albums\nP: List all your saved playlists\n\nPS: Print playlists sorted by their name\nPC: Print the content of a playlist\n\nh: print this help screen\nq: quit the program\n");
break;
case "q" : //quit
@@ -556,9 +595,13 @@ public class jMusicHub {
Playlist newPlaylist=addPlaylist(scan, songs, audiobooks);
if (newPlaylist != null){
int playlistsSize = playlists.size();
- Playlist lastObject=playlists.get(playlistsSize-1);
- int idOfLastObject = lastObject.getId();
- newPlaylist.setId(idOfLastObject+1);
+ if ( playlistsSize != 0){
+ Playlist lastObject=playlists.get(playlistsSize-1);
+ int idOfLastObject = lastObject.getId();
+ newPlaylist.setId(idOfLastObject+1);
+ } else {
+ newPlaylist.setId(playlistsSize);
+ }
playlists.add(newPlaylist);
System.out.println("\nActual content of your list (you must save it (s) to do anything else with them) :");
for (Playlist iPlaylist : playlists){
@@ -602,9 +645,12 @@ public class jMusicHub {
case "P": //print playlists sorted by id
listById("playlists");
break;
- case "PS": //print playslists sorted by their name
+ case "PS": //print playlists sorted by their name
listPlaylistsByName();
break;
+ case "PC":
+ contentOfPlaylist(playlists);
+ break;
default :
System.out.println("Unknown command. Type h for help.");
}
diff --git a/playlists b/playlists
index e201e98..7ea07a0 100644
--- a/playlists
+++ b/playlists
Binary files differ
diff --git a/run b/run
new file mode 100755
index 0000000..528673d
--- /dev/null
+++ b/run
@@ -0,0 +1,4 @@
+#!/bin/bash
+#coding: utf-8
+
+javac jMusicHub.java && java jMusicHub
diff --git a/songs b/songs
index 2208b77..d0de77c 100644
--- a/songs
+++ b/songs
Binary files differ