task 3
This commit is contained in:
@@ -8,5 +8,14 @@ class DataBase extends Serializable {
|
||||
def containsArtist(artist: Artist): Boolean = _artists.contains(artist)
|
||||
def getArtists(): Array[Artist] = _artists.toArray
|
||||
|
||||
def getArtistByName(name: String): Option[Artist] = {
|
||||
for (artist: Artist <- _artists) {
|
||||
if (artist.name == name) {
|
||||
return Some(artist)
|
||||
}
|
||||
}
|
||||
return None
|
||||
}
|
||||
|
||||
override def toString: String = s"<Database: ${_artists.length} artist(s)>"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user