@Override public String toString() { String result = "Song {title= '"+this.getTitle()+"', genre= '"+this.getGenre()+"', duration= '"+this.getDuration()+"', artists= ["; String separator = ""; for(int i = 0; i < this.artists.size(); i++){ result += separator+this.artists.get(i); if (i==0){ separator = ", "; } } return result+"]}"; }
@Override public String toString() { String result = "Song {id= "+this.id+", name= '"+this.getName()+"', year= "+this.year+", genre= '"+this.getGenre()+"', duration= '"+this.getDuration()+"', artists= ["; String separator = ""; for(int i = 0; i < this.artists.size(); i++){ result += separator+this.artists.get(i); if (i==0){ separator = ", "; } } return result+"]}"; }
public boolean isLongerThan(int seconds){ System.out.println("Calculating playlist lenght"); int calculatedTime = 0; for (Song song : songs) { calculatedTime += song.getDuration(); if (calculatedTime > seconds){ return true; } } return false; }
public boolean containsSong(String songName){ System.out.println("Searching for a song named '"+songName+"'"); for (Song song : songs) { if (song.getTitle().equalsIgnoreCase(songName)){ return true; } } return false; }
public boolean containsSong(String songName){ System.out.println("Searching for a song named '"+songName+"'"); for (Song song : songs) { if (song.getName().equalsIgnoreCase(songName)){ return true; } } return false; }
public boolean isLongerThan(int seconds){ System.out.println("Calculating playlist lenght"); int calculatedTime = 0; for (Song song : songs) { calculatedTime += song.getDuration(); if (calculatedTime > seconds){ return true; } } return false; }
public void accumulate(Serializable context, Object value) { if (((Song)value).getTitle().contains("a")){ ((ContextData)context).songs.add((Song)value); } }
@Override public String toString() { String result = "Song {id= "+this.id+", name= '"+this.getTitle()+"', year= "+this.year+", genre= '"+this.getGenre()+"', duration= '"+this.getDuration()+"', artists= ["; String separator = ""; for(int i = 0; i < this.artists.size(); i++){ result += separator+this.artists.get(i); if (i==0){ separator = ", "; } } return result+"]}"; }