In this assignment you will create the Unbounded Ocean that the biologists want (see the Problem Statement at the beginning of Part 2 of the Marine Biology Case Study).* To do this, you will create an unordered list (apvector) of the fish in the ocean rather than keeping a matrix of defined and undefined fish in all possible environment positions. Much of the change is restricted to the Environment class, because you are changing the internal representation of the environment.
operator<
for the Position class also. A position is
"less than" another position if it is above it (in a row with a lower
index) or if it is in the same row but to the left of it (lower column
index). Using ==, !=, and <, implement the remaining comparison
operators.
Modify the main function in fishsim.cpp to construct the Display by specifying an appropriate number of rows and columns (for example, 10 x 20).
Graphics-based versions: Make sure that your particular graphics version allows you to derive the number of rows and columns to be displayed from the size of the window and possibly "scaling factors" which describe the size of each "cell."
Fish undefinedFish;and then return the local undefinedFish object when necessary.
if (myFishCount == myWorld.length()) { myWorld.resize(2 * myWorld.length()); DebugPrint(7, "doubling length of myWorld to " + IntToString(myWorld.length())); }This increases the size of the vector if necessary. Then update the code to actually add the new fish to the vector rather than to a matrix.
One recommendation is to call Sort from the Simulation Step function. (Why is this a good place to put this call?)
*This lab was derived from the Advanced Placement Computer Science Marine Biology Simulation Case Study, available from the College Board for face-to-face teaching purposes.