Please mark every line that type-checks with a ÿ and every line that does not type-check with an x.
Code: Alles auswählen
case class Board(length: Int, height: Int) {
case class Coordinate(x: Int, y: Int) {
require(0 <= x && x < length && 0 <= y && y < height)
}
val occupied = scala.collection.mutable.Set[this.Coordinate]()
val b1 = Board(20, 20)
val b2 = Board(30, 30)
val b3: Board = b1
val b4: b1.type = b1
val c1 = b1.Coordinate(15, 15)
val c2 = b2.Coordinate(25, 25)
val c3 = b3.Coordinate(10,10)
val c4 = b4.Coordinate(10,10)
[ ] b1.occupied += c1
[ ] b2.occupied += c2
[ ] b1.occupied += c2
[ ] b1.occupied += c3
[ ] b2.occupied += c3
[ ] b1.occupied += c4
[ ] b2.occupied += c4
}