CSC 8310 -- Programming Languages
Villanova, Summer, 1998
David Matuszek

First Java assignment: Wator Application

"Wator" (a misspelling of "water") is a simple predator-prey simulation. I don't know the origins of this simulation, but the version I have was written by Robert Martin. In this simulation, there are sharks and tuna. Sharks move, eat tuna, and reproduce; they might starve to death. Tuna move and reproduce, and they always have enough to eat. Neither tuna nor sharks ever die of old age.

This simulation will use the following input parameters, to be read from the command line (or equivalent).

The ocean is an NxN array (the size N is an input parameter). Each location in the array can be empty, or it can hold one tuna or one shark (but not both). At the beginning of the simulation, put the tuna and sharks in random locations in the ocean.

The simulation progresses in a series of "steps." At each step, each tuna will

At each step, each shark will

Notice that tuna and sharks share a lot of the same behaviours. It might be a good idea to define a class Fish with extensions Tuna and Shark. Or maybe not; I'm really not sure.

Run the simulation for the given number of steps, and at each step print out the step number, the number of tuna, and the number of sharks. Optional: if you run out of tuna or sharks, the program could detect this and stop the simulation early.

Turn in:

It's the Java language that I'm concerned with, not the simulation. So if some details of the simulation aren't clear, just do something reasonable.

Note: The next Java assignment will build on this one, so it is important to get this one working.