added lesson 7

This commit is contained in:
2025-04-15 15:07:26 +02:00
parent 9ad00e6182
commit d8b22157c5
7 changed files with 98 additions and 8 deletions

View File

@@ -0,0 +1,16 @@
trait Logged {
def log(msg: String)
}
trait ConsoleLogger extends Logged {
override def log(msg: String) = println("[LOG] " + msg)
}
abstract class Person(name: String)
class Customer(n: String) extends Person(n) with Logged {
log(s"Person $n created")
}
val a = new Customer("Patrick Jane") with ConsoleLogger