package wq02
/*
特质
trait:实现多继承
*/
object class14 {
trait BeautifulEye {
val eye:String = "眼睛漂亮"
}
trait Tall {
val height:String = "高大个"
def run():Unit = {
println("run....")
}
def jump():Unit
}
// 继承 with
class Child extends BeautifulEye with Tall{
val name:String = "小花"
def jump(): Unit = {
println(s"${name}, jump...")
}
}
def main (args: Array [String]): Unit = {
val child = new Child()
println(child.eye)
println(child.height)
child run()
child jump()
}
}