trait Tdemo01 {
def add2(x:Int,y:Int):Int
def show2
}
trait Tdemo {
def add(x:Int,y:Int):Int
def show
}
import day03.Tdemo
class TraitDemo01 extends Tdemo with Tdemo01{
override def show: Unit = {
println("超超183")
}
override def add(x: Int, y: Int): Int = {
x+y
}
override def add2(x: Int, y: Int): Int ={
x-y
}
override def show2: Unit = {
println("宁宁168")
}
}
import day03.Tdemo
object TraitDemo {
def main(args: Array[String]): Unit = {
new Text with Tdemo with Tdemo01 {
override def add(x: Int, y: Int): Int = ???
override def show: Unit = ???
override def add2(x: Int, y: Int): Int = ???
override def show2: Unit = ???
}
}
}