Section 2

My first thought it that we have evidence here that we've been coding a little too loose here and have not written unit tests to validate all of that recent code incrementally. Let's look at the debugger and see if we can figure out where we went wrong. Let's look at that Grid>>calculatePath method.

This leads us to LaserPathElement>>nextElementIn:.

If we examine the instance variables for the current LaserPathElement we find we are on a Mirror Cell with an entrySide = #south. That sounds like we are in the first cell in our grid.

The value for loc confirms it. The value for dirSym looks correct. Here's a diagram of what we expected for our first cell in the grid.

We expect the laser beam to enter the cell by the #south side and exit by the #east side. This looks good. The value for newLoc is correct too.

Index Page Next Page

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