/* * Name : Playlist * * Description : The Playlist class is used to create playlists containing songs and audiobooks. * * Version : 1.0 * * Date : 28/12/2020 * * Copyright : Aimeric ADJUTOR */ import java.util.ArrayList; import java.io.Serializable; /** * The Playlist class is used to create playlists containing songs and audiobooks. * * @version 1.0 * @see Song * @see AudioBook * @author Aimeric ADJUTOR */ public class Playlist implements Serializable { private static final long serialVersionUID = 6021717365357635741L; private int id; private String name; private ArrayList songs = new ArrayList(); private ArrayList audiobooks = new ArrayList(); /** * Constructor method. * * @param name String * @param songs ArrayList * @param audiobooks ArrayList * * @see Song * @see AudioBook * * @author Aimeric ADJUTOR * */ public Playlist(String name, ArrayList songs, ArrayList audiobooks) { this.name=name; this.songs=songs; this.audiobooks=audiobooks; } /** * This method is used to give the id of the playlist. * * @return id int * * @author Aimeric ADJUTOR * */ public int getId(){return id;} /** * This method is used to give the name of the playlist in uppercase. * Using toUpperCase method because the way I sort by name sorts the upper case then the lower case, which is inconvenient. * * @return name.toUpperCase String * * @author Aimeric ADJUTOR * */ public String getName(){return name.toUpperCase();} /** * This method is used to print the each songs contained in the songs attribute of the playlist. * * @author Aimeric ADJUTOR * */ public void getSongs(){ for ( Song s : songs ){ System.out.println(s); } } /** * This method is used to print the each audiobooks contained in the audiobooks attribute of the playlist. * * @author Aimeric ADJUTOR * */ public void getAudioBooks(){ for (AudioBook b : audiobooks ){ System.out.println(b); } } /** * Basic method to set the id of the playlist. * * @param id int * * @author Aimeric ADJUTOR * */ public void setId(int id){this.id=id;} /** * Basic method to set the name of the playlist. * * @param name String * * @author Aimeric ADJUTOR * */ public void setName(String name){this.name=name;} /** * Basic method to "configure" what does a print of this object actually does. * * @return String, using the object's methods * * @author Aimeric ADJUTOR * */ public String toString() { return "Id : "+getId()+"\nName : "+getName(); } }