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 songs = new ArrayList(); public Album(String title, int duration, String artist, Date date, ArrayList 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 ArrayList getSongs(){return songs;} 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(); } }