Chapter 5, Exercise 6
Bruce suggests that we "Create a class with protected data. Create a second class in the same file with a method that manipulates the protected data in the first class."
package x;
class c5x6_parent {
protected var pd = 12;
}
class c5x6_child extends c5x6_parent {
def seeSet ( npd: Int ) : Int = {
val res = this.pd;
this.pd = npd;
res
}
}
object c5x6 {
def main ( args: Array[String] ) = {
val z = new c5x6_child;
Console.println( z.seeSet( 42 ) );
Console.println( z.seeSet( 69 ) );
}
}
10:02:32 PM