object PointMapApp extends App {
case class Point(x: Int, y: Int) {
def getX: Int = x
def getY: Int = y
}
// Create a map with Point keys and String values
val pointMap: Map[Point, String] = Map(
Point(2, 7) -> "A",
Point(3, 6) -> "B",
Point(0, 0) -> "C"
)
// Print x and y separately
for ((point, value) <- pointMap) {
println(s"x: ${point.getX}, y: ${point.getY} => $value")
}
}
/*
run:
x: 2, y: 7 => A
x: 3, y: 6 => B
x: 0, y: 0 => C
*/