37 lines
586 B
Vala
37 lines
586 B
Vala
public interface Drawable : Object {
|
|
|
|
public abstract void draw ();
|
|
}
|
|
|
|
public abstract class Figure : Object, Drawable {
|
|
public virtual void draw () {
|
|
stdout.printf ("Figure:draw() called\n");
|
|
}
|
|
}
|
|
|
|
public class Circle : Figure {
|
|
public override void draw () {
|
|
stdout.printf ("Circle:draw() called\n");
|
|
}
|
|
}
|
|
|
|
public class ColorCircle : Circle {
|
|
public override void draw () {
|
|
stdout.printf ("ColorCircle:draw() called\n");
|
|
}
|
|
}
|
|
|
|
void main () {
|
|
var cc = new ColorCircle ();
|
|
cc.draw ();
|
|
|
|
Circle c = cc;
|
|
c.draw ();
|
|
|
|
Figure f = c;
|
|
f.draw ();
|
|
|
|
Drawable d = f;
|
|
d.draw ();
|
|
}
|