Marine Biology Simulation |
.zip
file)
for the Marine Biology Simulation case study
Environment
. Note that
to put things other than Fish
in the MBS Simulation you will
also need to change the Simulation
code, which currently casts
all the Locatable
objects to Fish
objects before
calling the act
method. One possibility is
to create an Active
interface (containing only an act
method),
modify Fish
to implement Active
, and create
your boats or islands or whatever and have them implement
Active
also
(possibly with act
methods that do nothing). The
new altmbsgui.jar graphical user interface can handle both display classes
and images for Locatable
objects other than Fish
(by
extending AbstractLocatableDisplay
or using LocatableImageDisplay
).
If you add your new classes, such as Boat
or Island
,
to the array of classes passed to MBSFactory.addEnvObjClassNames
in MBSGUI.java
,
then you can also add/edit boats and islands in the Create Environment part
of the graphical
user interface. You can find examples of the Active
interface, modified
MBSGUI
, Fish
, and Simulation
classes, and new Island
, Rock
, and RockDisplay
classes here.if
statements and using the Random
classRandom
class, with a follow-up
exercise using an array of integers (this project uses a BoundedEnv
object for plotting the histogram, although students don't have to be
aware of that)BoundedGrid
object (very similar to a BoundedEnv
),
plotting pictures by placing colored blocks in the grid; graphics is
all behind
the scenesFish
class. In this project students enhance the way minnows move in
their environment, going from simple forward movement to the random movement
exhibited by fish in the MBS Fish
class. It not only
allows students to become familiar with a simplified version of the Fish
class, but also with the getDirection
and getLocation
methods in Environment
. Students should be familiar
with constructing objects, invoking methods, basic flow control constructs,
implementing classes, and the add
, get
, remove
,
and size
methods of the ArrayList
class before
attempting this project. You may also want to have them read about
the Environment
interface at the beginning of Chapter 2 and
do the first two Exercise Sets in that chapter before completing the Minnow
Project.Random
class. A follow-up
exercise introduces an array of integers. This project uses a BoundedEnv
object behind the scenes for plotting the histogram.BoundedEnv
data structure by placing colored block objects in the environment.
A row-major traversal method is provided; students implement a column-major
traversal, draw diagonals and a border around the perimeter, and so forth.
The program "automagically" places a button on the graphical
user interface for each method students implement. Students receive visual
feedback about the correctness of their algorithms without having to write
any graphics code.Fish
class until
it behaves like the actual MBS Fish
class. Students
become familiar with the getDirection
and getLocation
methods in Environment
.BoundedEnv
data structure.BoundedEnv
object as the N x N board.Compiling and Executing the MBS Program
- The
ExecutionInformation
folder in the distribution file has information about running the case study with several versions of CodeWarrior (Macs, PCs, UNIX), from TextPad (PCs), or from the command line under DOS, Windows, Linux, or UNIX (including OS X).- The easiest way to run the MBS case study under BlueJ is to download the BlueJ version of the MBS distribution. (You do not need to delete the standard distribution folder, just leave the two of them side-by-side.) BlueJ works under Mac OS X, Windows, Linux, and UNIX.
- Cay Horstmann has provided instructions on running the MBS under Eclipse. Eclipse works under Mac OS X, Windows, Linux, and UNIX.
Black Box Source Code
- Source Code for MBS Black Box Classes (the classes in
mbsbb.jar
) (You do not need to have or to look at the source code for these classes in order to compile or run the MBS program. The source code is provided here merely for those who are interested in looking under the covers.)- Source Code for the MBS Graphical User Interface (the classes in
mbsgui.jar
) (You do not need to have or to look at the source code for these classes in order to compile or run the MBS program. The source code is provided here merely for those who are interested in looking under the covers.)
*AP and Advanced Placement are registered trademarks of the
College Entrance Examination Board, which has not endorsed this website.
Last modified on
5 January 2019
by Alyce Brady.