Appendix B

Source for the Billiards Game

This appendix lists the complete source for the billiards simulation described in Chapter 7.

B.1 ⊡ The Version without Inheritance

unit GraphicsEx;

(*
       Billiards Simulation Program
       Written by Tim Budd, July 2001 *) interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TBall = class(TObject) public constructor create (ix, iy : Integer; iLink : TBall); procedure draw (canvas : TCanvas); function hasIntersected(aBall : Tball) : Boolean; procedure hitBy (aBall : TBall); procedure update; procedure setCenter (nx, ny : Integer); procedure setDirection (nd : Real); private x, y : Integer; direction : Real; energy : Real; ...

Get An Introduction to Object-Oriented Programming, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.