13.15 模拟枚举类
package com.atguigu.day11.moshipipei
object EnumDemo {
def main(args: Array[String]): Unit = {
val seasons = Array(Spring, Summer, Autumn, Winter)
for (season <- seasons) {
val msg = season match {
case Spring => "春天"
case Summer => "夏天"
case Autumn => "秋天"
case Winter => "冬天"
case _ => "每在地球上"
}
println(msg)
}
}
}
sealed abstract class Season
case object Spring extends Season
case object Autumn extends Season
case object Summer extends Season
case object Winter extends Season