22 lines
642 B
Scala
22 lines
642 B
Scala
package ch.hevs.isc.slopify_v2
|
|
|
|
import scala.collection.mutable.ArrayBuffer
|
|
|
|
class DataBase extends Serializable {
|
|
private var _artists: ArrayBuffer[Artist] = new ArrayBuffer()
|
|
def addArtist(artist: Artist): Unit = _artists.addOne(artist)
|
|
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)>"
|
|
}
|