Section 3

We need a place to store and manage these forms. We'll just create them and hold onto them for later use. Create a new subclass of Object as LaserGameForms. The new class has no instance variables but does have a class variable named "CachedForms".

Here's a new class method with code that should look pretty familiar.

Write the 4 methods to describe each arrow.

Create the method that will create our cached forms.

Now we can write the methods that will answer our arrow forms.

We're using lazy initialization to instantiate our class variable for the cached forms. Once any one of these forms are requested, they will all be created. The code that initializes our cache could eventually be modified to load these forms from an external resource.

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels    stevewessels@me.com