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

Graphical Object Class

Every graphical object has a link field and a region of space.

Wall = object 
	link : Wall;        (* data fields *)
	region : Rect;
		(* factor used to reflect striking balls *)
	convertFactor : real;

	procedure initialize  (* initialization function *)
		(left, top, right, bottom : integer; cf : real);

	procedure draw;	 (* draw wall *)

		(* notify wall that a ball has struck *)
	procedure hitBy (aBall : Ball);
end;
Intro OOP, Chapter 6, Slide 4