private static void printAlbumSong(List<Album> albumList) { ListIterator<Album> albumIterator = albumList.listIterator(); ListIterator<Song> songIterator; System.out.println("You have: "); while (albumIterator.hasNext()) { Album album = (Album) albumIterator.next(); System.out.println("Album [" + albumIterator.nextIndex() + "] : " + album); songIterator = album.getSongList().listIterator(); while (songIterator.hasNext()) { Song song = (Song) songIterator.next(); System.out.println("Song [" + songIterator.nextIndex() + "] : " + song); } } }
private static void removeCurrentSong() { if (currentSong != null) { System.out.println("Removing >> " + currentSong); iterator.remove(); if (iterator.hasNext() || iterator.hasPrevious()) { if (forward) { if (!iterator.hasNext()) { iterator.previous(); } playNextSong(); } else { if (!iterator.hasPrevious()) { iterator.next(); } playLastSong(); } } else { System.out.println("No song in the list.."); currentSong = null; } } else { System.out.println("No song in the list.."); } }
private static void listSong() { System.out.println("--- Play List ---"); for (Song song : playList) { System.out.println(song); } System.out.println(""); }
private static void replay() { System.out.println("Now is playing >> " + currentSong); }
private static void playLastSong() { if (!forward) { if (iterator.hasPrevious()) { currentSong = iterator.previous(); System.out.println("Now is playing >> " + currentSong); } else { System.out.println("You are at the start of list.."); } } else { if (iterator.hasPrevious()) { iterator.previous(); if (iterator.hasPrevious()) { currentSong = iterator.previous(); System.out.println("Now is playing >> " + currentSong); forward = false; } else { System.out.println("You are at the start of list.."); } } else { System.out.println("You are at the start of list.."); } } }
private static void playNextSong() { if (forward) { if (iterator.hasNext()) { currentSong = iterator.next(); System.out.println("Now is playing >> " + currentSong); } else { System.out.println("You are at the end of list.."); } } else { if (iterator.hasNext()) { iterator.next(); if (iterator.hasNext()) { currentSong = iterator.next(); System.out.println("Now is playing >> " + currentSong); forward = true; } else { System.out.println("You are at the end of list.."); } } else { System.out.println("You are at the end of list.."); } } }
private static void printMenu() { System.out.println("--- Player Menu ---"); System.out.println("0. Quit"); System.out.println("1. Skip forward"); System.out.println("2. Skip backfard"); System.out.println("3. Replay"); System.out.println("4. List songs"); System.out.println("5. Remove current song"); System.out.println("6. Show menu"); System.out.println(""); } }