CIT 591 Assignment 8: Important Changes to Wator Applet
Fall 2003, David Matuszek

In the Wator assignment, I wrote:

At each turn, the Controller should tell the Model to take one step, then it should tell the View to display the result. (Next week I will discuss a better way to handle the interaction between classes, so this part is temporary.)

The Model:

The model class, Ocean, should import java.util.Observable, and it should extend Observable. In addition, I wrote:

public void step()
Executes one step in the simulation. See below for details on what happens during a step.

The last thing that step() should do before it returns is to call setChanged() and notifyObservers().

The GUI:

The View class (whatever it's called) should implement Observer, and somewhere near the start of the program, should say something like model.addObserver(view). (Your names may vary.)

The GUI also has to create a separate Thread for the Model. In the example I presented in class, the necessary run() method was in the Model; due to the way I've defined the program, this has to be done in the GUI. If you understand Threads, this should not be difficult. This run() method should tell the Model to make a step every so often, but it should not tell the View to display anything--the View should be observing the Model.