task 2
This commit is contained in:
@@ -2,8 +2,11 @@ package ch.hevs.isc.slopify_v2
|
||||
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
class Album(val name: String) {
|
||||
private var songs: ArrayBuffer[Song] = new ArrayBuffer()
|
||||
def addSong(song: Song): Unit = songs.addOne(song)
|
||||
def containsSong(song: Song): Boolean = songs.contains(song)
|
||||
class Album(val name: String) extends Serializable {
|
||||
private var _songs: ArrayBuffer[Song] = new ArrayBuffer()
|
||||
def addSong(song: Song): Unit = _songs.addOne(song)
|
||||
def containsSong(song: Song): Boolean = _songs.contains(song)
|
||||
def getSongs(): Array[Song] = _songs.toArray
|
||||
|
||||
override def toString: String = s"<Album '$name': ${_songs.length} song(s)>"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user