/* * Search songs in the playlist * @param: option: title or artist * @param: string of words */ private void search(String option, String words) { if (option.equals("title")) { for (SongFile sf : this.songs) { if (sf.getTitle().toLowerCase().contains(words)) { sf.printSong(); } } } else if (option.equals("artist")) { for (SongFile sf : this.songs) { if (sf.getArtist().toLowerCase().contains(words)) { sf.printSong(); } } } else { System.out.println("Error: wrong option for search."); } }
/* * Print playlist based on option * @param: option: title or artist * * Default order is the inserted order. * If the option is not title nor artist, using the default order. */ private void print() { ArrayList<SongFile> tmp = new ArrayList<SongFile>(this.songs); if (currentOrder.equals("title")) { Collections.sort(tmp, new CompareByTitle()); } else if (currentOrder.equals("artist")) { Collections.sort(tmp, new CompareByArtist()); } for (SongFile sf : tmp) { sf.printSong(); } }