Page157 - SniperTableModelTest

To get the new values visible on screen, we need to fix
SnipersTableModel so that it makes them available to its JTable, starting
with a unit test. We take a small design leap by introducing a Java enum
to represent the columns in the table

The table model needs to do two things when its state changes: hold onto
the new values and notify the table that they've changed.
Page159 - SnipersTableModelTest implementation

We provide an initial SniperState with empty values so that the
table model will work before the Sniper has connected.
For the dimensions, we just return the numbers of values in Column or a
hard-coded row count.
This method unpacks the value to return depending on the column that is
specified. The advantage of using an enum is that the compiler will help
with missing branches in the switch statement (although it still insists
on a default case). We're not keen on using switch, as it's not
object-oriented, so we'll keep an eye on this too.
The Sniper-specific method. It sets the fields and then triggers its
clients to update.
Page160 - Refactoring SniperSnapshot from State

We realize that we could collapse our events into one notification that
includes the prices and the Sniper status. Of course we're transmitting
the same information whichever mechanism we choose-but, looking at the
chain of methods calls, it would be simpler to have just one method and
pass everything through in SniperState. Having made this choice, can we do
it cleanly without ripping up the metaphorical floorboards? We believe
we can-but first, one more clarification. We want to start by
creating a type to represent the Sniper's status (winning, losing,
etc.) in the auction, but the terms status and state are too close to
distinguish easily. We kick around some vocabulary and eventually decide
that a better term for what we now call SniperState would be
SniperSnapshot: a description of the Sniper's relationship with the
auction at this moment in time. This frees up the name SniperState to
describe whether the Sniper is winning, losing, and so on, which matches
the terminology of the state machine