task 3
This commit is contained in:
@@ -8,5 +8,14 @@ class Album(val name: String) extends Serializable {
|
||||
def containsSong(song: Song): Boolean = _songs.contains(song)
|
||||
def getSongs(): Array[Song] = _songs.toArray
|
||||
|
||||
def getSongByTitle(title: String): Option[Song] = {
|
||||
for (song: Song <- _songs) {
|
||||
if (song.title == title) {
|
||||
return Some(song)
|
||||
}
|
||||
}
|
||||
return None
|
||||
}
|
||||
|
||||
override def toString: String = s"<Album '$name': ${_songs.length} song(s)>"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user