blob: a83eefe972dbecd3b2b77c0c8277a50e2769105b (
plain) (
tree)
|
|
class Quantity {
def getValue = 0;
def connect(c: Constraint) = c.newValue;
}
abstract class Constraint(q: Quantity) {
def newValue: Unit;
q connect this
}
class Adder(q: Quantity) extends Constraint(q) {
def newValue = System.out.println(q.getValue);
}
object Main {
def main(args: Array[String]): Unit = {
val x = new Quantity;
new Adder(x);
()
}
}
|