The Last Queen

One issue we have not addressed in the pseudo-code descriptions of the algorithm is how to handle the leftmost queen, the queen that does not have any neighbor. There are two broad solutions to this problem.

The first solution is to give this queen a null pointer. This means each queen must always test this pointer value before sending any messages.

A second solution, in many ways a more object-oriented one, is to create a special sentinel value that indicates the end of the line for the list of queens. This sentinel value responds to the same messages as the queens, but performs different actions (and, in particular, unlike the queens does not pass messages on to another object).

Both versions are described in the text. We do not here in the slides go through the various solutions in detail. However, you should at this point read chapter 5 and examine how this problem is solved in the different languages.

[audio] [real] Text to accompany slide13, in Chapter 5 of An Introduction to Object-Oriented Programming