aboutsummaryrefslogtreecommitdiff
path: root/Playlist.java
blob: b4251d3c6c8d56e82346f8d85a18ac50867db41e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * 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<Song> songs = new ArrayList<Song>();
	private ArrayList<AudioBook> audiobooks = new ArrayList<AudioBook>();

/**
 * Constructor method.
 *
 * @param 	name String
 * @param 	songs ArrayList
 * @param 	audiobooks ArrayList
 *
 * @see 	Song
 * @see 	AudioBook
 *
 * @author 	Aimeric ADJUTOR
 * */
	public Playlist(String name, ArrayList<Song> songs, ArrayList<AudioBook> 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()+"\n";
	}
}