Section 3

Write the following method for all three click region classes.

Now that we have rectangle defined for each click region class, it should be easy to write the method that finds the correct one.

There's a pretty good chance that solution will not work for every case. It's easy to see that the inside region, outside region and ignore region will all say they "own" a test point sufficiently close to the center.

The solution is to control the prioritization of the click region subclasses as they claim a point within the cell. The inside-most click-region should be first in order, the ignore region last. We can implement methods that provide this prioritization as follows.

The methods to answer the sorted priority-ordered click-region classes and the new code to use the priorities looks like this:

The unit test work we have yet to do will draw this design detail out. Let's run what we have so far.

So far, the easy case worked.

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels