Introduction to OOP: Chapter 6: Case Study: A Billiards Game [next] [previous] [audio] [real] [text]

Graphical Objects can Draw themselves

procedure Wall.draw;
begin
	PaintRect (region);
end;

procedure hole.draw;
begin
	PaintOval (region);
end;

procedure Ball.draw;
begin
	if self = CueBall then
			(* draw an open circle *)
		FrameOval (region)
	else
			(* draw a filled circle *)
		PaintOval (region)
end;
Intro OOP, Chapter 6, Slide 6