Creating a new Species class

The New York ecologists want to study competing species of fish that occur in lakes in upstate New York. They have species that require the same resources and can live in essentially the same conditions, but find that in different lakes, different species dominate, even after stocking the lakes with several different species. They would like to adapt the MBCS model with breeding and dying to accomodate different species so that they may study this phenomenon.

The ecologists want to make the same assumptions about the fish as in the programming assignment for Aging, Breeding, Dying, except that the probabilities of breeding and dying are determined by the species of the fish:

The ecologists would like to distinguish fish of different species and of different ages in the display:

The ecologists would also like to record how the populations grow or decline over time, so that the population time series can then be displayed using a standard spreadsheet program.

Assignment

Start with the program created for the programming assignment in unit Aging, Bredding, Dying, that has fish that breed and die. Dupplicate your LiveBreedDie folder and call it Spicies.

  1. Create a new class, Species to represent a species of fish
  2. Modify the fish data file format for the fish simulation as follows
  3. Add a new data member for the Fish class, mySpecies, with type Species.
  4. Modify the Environment constructor so that it reads the species from the fish data file and records them in a vector, then reads the fish in and assigns each fish a species as indicated in the fish data file.
  5. Modify the fish member functions involved in fish breeding and dying so that they use the probabilities given for the fish's species.
  6. Modify the fish member function ShowMe so that the character returned is based on the fish's species' ShowMe result and not on the fish ID.
  7. Modify or add appropriate calls to DebugPrint to aid in testing your program.
  8. Create some fish data files and test your new program. To begin with, work with small grids and small numbers of fish and use the debugging facility.
  9. Create a new class, FishLog, for recording the changes in the species populations over time
  10. Modify the main function in the fishsim.cpp file
  11. Test the operation of the recording function with small numbers of fish.

Now the biologists have a tool with which they can experiment with different species in a meaningful way. You might try experimenting to see if you can find, say, three species that compete within the parameters of the simulation such that no one species always wins out. A sample data file for a 50x50 grid that gives interesting results is provided here. fishspec.dat.

What to turn in