abstract class Engineer {
println ("class Engineer constructor")
def work(time:Int)
}
class Person extends Engineer {
println ("class Person constructor")
def work(time:Int) {
println ("Person#work start")
println ("1つのタスクを"+time+"分で行います")
println ("Person#work end")
}
}
trait Programmer extends Engineer {
println("trait Programmer constructor")
abstract override def work(time:Int) = {
println("Programmer#work start")
super.work(time - 15)
println("Programmer#work end")
}
}
trait Agiler extends Engineer {
println("trait Agiler constructor")
abstract override def work(time:Int) = {
println("Programmer#work start")
super.work(time / 2)
println("Programmer#work end")
}
}
object Engineer {
def main(args: Array[String]) {
var p4 = new Person with Programmer with Agiler
println(p4.work(60))
var p3 = new Person with Agiler with Programmer
println(p3.work(60))
}
}