aboutsummaryrefslogtreecommitdiff
path: root/Album.java
blob: 7b30ca106dd776a9f0248f3a3185cc012993b545 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
 * Name 	: Album
 *
 * Description 	: The Album class is used to create albums containing songs added after its creation and the creation of the songs
 *
 * Version 	: 1.0
 *
 * Date 	: 28/12/2020
 *
 * Copyright 	: Aimeric ADJUTOR
 */

import java.util.*;
import java.io.Serializable;

/**
 * The album class is used to create albums containing songs added after its creation and the creation of the songs.
 *
 * @version 	1.0
 *
 * @see 	Song
 * @author 	Aimeric ADJUTOR
 */

public class Album implements Serializable {
	private static final long serialVersionUID = -8678385322105507976L;

	private int id, duration;
	private Date date;
	private String title, artist;
	private ArrayList<Song> songs = new ArrayList<Song>();

/**
 * Constructor method.
 *
 * @param 	title String
 * @param 	duration int, calculated with the actual duration of the object's songs
 * @param 	artist String
 * @param 	date Date
 * @param 	songs ArrayList
 *
 * @see 	MusicalElement
 *
 * @author 	Aimeric ADJUTOR
 * */
	public Album(String title, int duration, String artist, Date date, ArrayList<Song> songs) {
		this.title=title;
		this.duration=this.getDuration();
		this.artist=artist;
		this.date=date;
		this.songs=songs;
	}
/**
 * This method is used to give the id of the album.
 *
 * @return 	It returns the id, which is an int.
 *
 * @author 	Aimeric ADJUTOR
 * */
	public int getId(){return id;}

/**
 * This method is used to give the title of the album.
 *
 * @return 	It returns the title, which is a String.
 *
 * @author 	Aimeric ADJUTOR
 * */
	public String getTitle(){return title;}

/**
 * This method is used to give the duration of the album.
 * It calculates it by getting the duration of each songs.
 *
 * @return 	It returns the total duration, which is an int.
 *
 * @see 	Song#getDuration
 *
 * @author 	Aimeric ADJUTOR
 * */
	public int getDuration(){
		for (Song s : songs) {duration+=s.getDuration();} //increase with each song's getDuration()
		return duration;
	}

/**
 * This method is used to give the artist of the album.
 *
 * @return 	It returns the artist, which is a String.
 *
 * @author 	Aimeric ADJUTOR
 * */
	public String getArtist(){return artist;}

/**
 * This method is used to give the date of release of the album.
 *
 * @return 	It returns the date, which is a Date.
 *
 * @author 	Aimeric ADJUTOR
 * */
	public Date getDate(){return date;}

/**
 * This method is used to print the each songs contained in the songs attribute of the album.
 *
 * @author 	Aimeric ADJUTOR
 * */
	public void getSongs(){
		for ( Song s : songs ){
		    System.out.println(s);
		}

	}

/**
 * This method is used for the AG command in jMusicHub.
 * It's searching for the irst song in the ArrayList songs and takes it's name.
 *
 * @return 	The genre, a Genre object, is returned.
 *
 * @see 	Song#getGenre
 * @see 	jMusicHub#listAlbumsByGenre
 *
 * @author 	Aimeric ADJUTOR
 * */
	public String getGenre(){ //used for AG
		Song firstSong=this.songs.get(0);
		String firstSongGenre = firstSong.getGenre();
		return firstSongGenre;
	};

/**
 * Basic method to set the id of the album.
 *
 * @param id int
 *
 * @author 	Aimeric ADJUTOR
 * */
	public void setId(int id){this.id=id;}

/**
 * Basic method to set the title of the album.
 *
 * @param title String
 *
 * @author 	Aimeric ADJUTOR
 * */
	public void setTitle(String title){this.title=title;}

/**
 * Basic method to set the artist of the album.
 *
 * @param artist String
 *
 * @author 	Aimeric ADJUTOR
 * */
	public void setArtist(String artist){this.artist=artist;}

/**
 * Basic method to set the date of the album.
 *
 * @param date Date
 *
 * @author 	Aimeric ADJUTOR
 * */
	public void setDate(Date date){this.date=date;}

/**
 * Mehtod to add songs, of the Song class, to the album's arrayList.
 *
 * @param song Song
 *
 * @author 	Aimeric ADJUTOR
 * */
	public void addSong(Song song){
		this.songs.add(song);
	}

/**
 * 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()+"\nTitle : "+getTitle()+"\nDuration : "+getDuration()+"\nArtist : "+getArtist()+"\nDate of release : "+getDate();
}

}