Section 2

We have some kind of behavior that tells us the code goes into a loop but examination so far shows everything looks good. However, it is suprising we are only on the first cell encountered by the laser beam. Perhaps that's also a good clue.

Let's drop into the code and single-step our way through this algorithm with the debugger. Doing this step-by-step in this tutorial will seem a bit tedious but we should not need to endure much longer before we find our elusive bug.

Click "restart" in the debugger. Press the "over" button in the debugger a few times until we get to this condition of execution.

If we examine the instance variables for "loc", "dirSym", "direction", "vector", "newLoc" and "nextCell", everything looks correct. We expect the next cell to be at location 2@5 and that it's a blank cell. Our dirSym value (the direction our laser is now traveling) looks correct.

Okay, it looks like our next step of execution will create a new LaserPathElement object. Single-step with the debugger using the "over" button until we're about to create the new object.

Index Page Next Page

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