Home | About | Calendar | Projects | Assignments | Classes | Resources
{Programming III }
     
 
ASSIGNMENT 7
 
REMINDERS
 
.Change myWorld to an apvector of pointers to Fish.

The drawback of the latest version of the case study (sorted apvector using Binary Search) is that the all of the shifting that we do to keep the Fish in myWorld in order, is expensive. Removing, Adding and Moving Fish each cause shifts to occur. A much cheaper way of shifting is to shift pointers instead of shifting actual Fish. Remember, pointers are just integer values, so shifting them is much cheaper than calling the copy constructor for class Fish, which in turn calls the copy constructor for class Position.

Your task is to modify class Environment so that myWorld has the following definnition:

apvector <Fish *> myWorld;

With this done, the Environment class will no longer compile. You will need to go in to any member function of class Environment and change the references to myWorld items so that they dereference the thing that they are pointing to.

.Optional.

Modify the Display class Show() member function so that the number of Fish in the world is always displayed in the upper, right-hand corner.

.Scoring.

This is not a project, but we will work on it in class. It will be a 100 point assignment.

.Resources.

[ The Marine Biology Case Study ]

  You can also implement other operators if you like, but they will not be necessary.
 
Page prepaed by Christian Day.
Site design by Kelly Moran
BackForward
 
 
Last Updated: