(* Daniel Blanchard - CISC672 - Dr. Pollock 9/5/2006 This program tests scoping in Cool. *) class B inherits A { z : Int <- 4; z(z : Int) : Int { (let z : Int <- z in z+y() ) }; v(v : Int) : Int { v }; }; class A inherits IO { x() : Int {5}; y() : Int {8}; }; class C inherits B { x() : Int {3}; }; class D inherits C { x() : Int { 4 }; y() : Int {9}; }; class E inherits A { a : A <- new A; b : B <- new B; c : C <- new C; d : D <- new D; z : Int <- 5; x() : Int { (b)@B.x()/b.z(z)/c.x()+b.v(d.x()) }; }; class Main inherits IO { main() : Object { { out_string("Should output 5: "); out_int((new A).x()); out_string("\nShould output 4: "); out_int((new D).x()); out_string("\nShould output 3: "); out_int((new C).x()); out_string("\nShould output 18: "); out_int((new B).z(10)); out_string("\nShould output 9: "); out_int((new B).v((new D).y())); out_string("\nShould output 4: "); out_int((new E).x()); out_string("\n\n"); out_string("Interactive test, enter numeric value: "); out_int((new B).z(in_int())*(new C).y()); out_string("\n"); } }; };