









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










class Point { x : Int 0; y : Int; ( use default value ) };
class Point { x : Int 0; y : Int 0; movePoint(newx : Int, newy : Int): Point { { x newx; y newy; self; } -- close block expression }; -- close method }; -- close class
x y 0 0
movePoint
x y 0 0
methods movePoint
class ColorPoint inherits Point { color : Int 0; movePoint(newx : Int, newy : Int): Point { { color 0; x newx; y newy; self; } }; }; x y 0 0
color 0
movePoint
x : P; x new C;
p : Point; p new ColorPoint; p.movePoint(1,2);
p has static type Point p has dynamic type ColorPoint p.movePoint must invoke the ColorPoint version