This week we'll have some fun with Java. Your program this week must do the following:
ImageIcon
.
ImageIcon
.
These rules must be applied simultaneously to the entire grid of cells. (In other words, the new values for the cells can't be plugged back into the original matrix until you compute the entire next step, or the intermediate changes will impact the results of the cells which have not yet been computed!)
Runnable
interface. You'll need a Thread
reference as a data member
of your class so you can signal your Life-iterator thread that it's
time to stop iterating. For more information on threads, read through the
java
tutorial on threads, especially these sections:
run
method
Runnable
interface
Ignore the other sections for now; we'll deal with them later.
Lab5
which handles command
line arguments (if there are any), creates the graphical interface, starts it
up, and does nothing else.
Life
whose instances hold the state and
perform updates for a single life board. This class has nothing to do with
the graphical interface, so it shouldn't have references to any graphical
objects whatsoever. It should be usable on its own if desired.
LifeGUI
whose instances contain a
Life
instance as a field. This class will implement the
Runnable
interface in order to permit the creation and
management of threads. This class will also have a two-dimensional array of
LifeButton
s (see below). The purpose of this class is to
display the states of the LifeButton
s, to allow the user to
interact with the buttons and start or stop the board update, and to
coordinate the updating of the Life
instance, which holds the
real state of the board.
LifeButton
whose instances hold the
state for a single location on the life board. They should also have a
reference to a Life
instance in order to change the state of
that instance when the button is clicked. In addition, this class must have
a method that allows the LifeGUI
instance to flip the state of
the button when the board is updating itself.
LifeGUI
class to
implement the response to clicking on the "go", "stop", and "next" buttons.
JSlider
, a JComboBox
, or a creative
combination of multiple presses of your Go button combined with a
label displaying the current throttle setting.