aboutsummaryrefslogtreecommitdiff
path: root/Album.java
blob: e2de48fae45dca4fedcda5f5426a040c5974c870 (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
import java.util.*;
import java.io.Serializable;

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>();

	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;
	}

	public int getId(){return id;}
	public String getTitle(){return title;}

	public int getDuration(){
		for (Song s : songs) {duration+=s.getDuration();} //increase with each song's getDuration()
		return duration;
	}

	public String getArtist(){return artist;}
	public Date getDate(){return date;}
	public void getSongs(){
		for ( Song s : songs ){
		    System.out.println(s);
		}

	}


	public void setId(int id){this.id=id;}
	public void setTitle(){this.title=title;}
	public void setArtist(){this.artist=artist;}
	public void setDate(){this.date=date;}

	public void addSong(Song song){
		this.songs.add(song);
	}

	public String toString() {
		return "Id : "+getId()+"\nTitle : "+getTitle()+"\nDuration : "+getDuration()+"\nArtist : "+getArtist()+"\nDate of release : "+getDate();
}

}