Example: displaying shapes in list
forall s:Shape in scene do
if s.is_rectangle() then
rectangle(s).draw();
elseif s.is_square() then
square(s).draw();
elseif…
else
error(“unknown shape”);
fi
end
forall s:Shape in scene do
s.draw();
end
Add new shapes?
Previous slide
Next slide
Back to first slide
View graphic version