Java Reference
In-Depth Information
As we have done in previous chapters, we will start with a version of an application that works
perfectly well from a user's point of view but whose internal view is not so good when judged by
the principles of good object-oriented design and implementation. We will use this base version
to develop several improved versions that progressively introduce new abstraction techniques.
One particular problem that we wish to address in the base version is that it does not make good
use of the inheritance techniques that were introduced in Chapter 8. However, we will start by
examining the mechanism of the simulation, without being too critical of its implementation.
Once we understand how it works, we shall be in a good position to make some improvements.
Predator-prey modeling There is a long history of trying to model predator-prey relationships
mathematically before the invention of the computer, because they have economic, as well as envi-
ronmental, importance. For instance, mathematical models were used in the early twentieth century
to explain variations in the level of fish stocks in the Adriatic Sea as a side effect of World War I. To
find out more about the background of this topic, and perhaps gain an understanding of population
dynamics, do a web search for the Lotka-Volterra model.
10.2.1 The foxes-and-rabbits project
Open the foxes-and-rabbits-v1 project. The class diagram is shown in Figure 10.1.
Figure 10.1
Class diagram of the
foxes-and-rabbits
project
SimulatorView
Simulator
FieldStats
Counter
Field
Location
Fox
Rabbit
Randomizer
 
Search WWH ::




Custom Search