I need help with this C project Assignment PredatorPrey For
I need help with this C++ project
Assignment: Predator/Prey
For this project, you will implement a simulation for predicting the future populations for a group of animals that we’ll call prey and their predators. Given the rate at which prey births exceed natural deaths, the rate of predation, the rate at which predator deaths exceeds births without a food supply, and the increase of the predator population in the presence of a food source, as well as the initial populations of the prey and their predators, we can predict future population sizes, using these formulas:
preyn+1= preyn × (1+AB × predn)
predn+1 = predn ×(1 C +D × preyn )
Where:
preyn is the population of the prey at time step n
A is the rate at which prey birth exceed natural deaths
B is the rate of predation
predatorn is the population of the predators at time step n
C is the rate at which predator deaths exceeds births without a food supply
D is the increase of the predator population in the presence of a food source
Therefore, given a set of initial conditions and the population at time step 0, the size of the populations can be predicted ‘x’ time steps, or periods into the future.
To implement this simulation, your program will read in the values for A, B, C, and D from a file along with the initial population sizes for the prey and predators. The file will contain data for one or more simulations. For each simulation, you will collect data on both population sizes until one of the populations goes to zero. Finally, you print to a file a simple graph representing this data, one for each simulation.
Files
You will be provided with a file called sim.dat, which will contain the data for all of the simulations.
Each line of the file will contain data for one simulation in the following order:
A B C D initialPreyPopulation initialPredatorPopulation
Therefore, a file with data for two simulations would read as follows:
0.1 0.01 0.01 0.00002 1000 20
0.5 0.02 0.01 0.0003 2000 50
For each run of your simulation, you will have to read in a line of data.
As you run each simulation, you will have to collect data on the number of time steps and the populations of the predators and prey at these time steps. This information will be printed as a graph to an output file. To print the graph, you will be provided with a function called printGraph, which you will find in the file, ‘PredatorPrey.cpp’. The printGraph function takes as parameters the output file stream, the simulation number, a vector of integers, the maximum size of the predator or prey population, and the number of generations for this simulation (the number of times the simulation looped until one of the populations went to 0 or below).
The integers in the vector will represent information about a given time step and the population of the prey and predators at that time step in an ordered triplet. For instance, if at time step 0, the population of the prey is 1000 and the predators’ population is 20; at time step 1, the population of the prey is 950 and the predators’ is 19; and at time step 2, the prey population 900 and the predators’ is 18, the first entries in the vector would look
0
1000
20
1
950
19
2
900
18
As part of your implementation of the simulation, you will be required to create two new classes, one called Predator and one called Prey. You are given the header file for Prey.h. You are given a ‘skelton’ header file for Predator.h. You need to create definitions for the mutators/accessors in Predator.h. You need to implement all the mutators and accessors in these classes (the ‘.cpp’ files). Your main function is defined in a file called PredatorPrey.cpp. Add the appropriate code where you see:
/* Your solution goes here */
Sample Output
For your program to work properly, it must execute using the following syntax:
Please Remember
Name your project PredPrey.
You are given the ‘complete’ header file, Prey.h. There are no modifications necessary to this file.
You are given the ‘incomplete’ header file, Predator.h. There ARE modifications necessary to this file.
You need to implement the class files Prey.cpp and Predator.cpp.
You are given the ‘incomplete’ ‘main’ program, PredatorPrey.cpp. There ARE modifications necessary to this file.
Read the comments for clues about what is required.
Both classes you will create have a mutator named ‘getNextPopulation’. If the ‘next’ population goes below 0 (zero), this mutator shall return 0 (zero).
If your code is working correctly, your output should be identical to PredPrey.txt
Here are the included files for the Assignment:
Predator.cpp:
Prey.h:
Predator.h:
Finally, the sim.dat file:
0.2 0.005 0.003 0.00002 980 17
0.5 0.02 0.01 0.0003 2000 50
0.1 0.01 0.01 0.00002 500 5
0.1 0.01 0.01 0.00002 500 50
0.3 0.05 0.02 0.00002 980 5
0.1 0.01 0.01 0.00002 1000 20
0.3 0.02 0.06 0.0004 300 25
Prey.cpp and Predator.cpp have to be created from scratch.
I can\'t even figure out where to begin, let alone how to make this simulation work
| 0 | 1000 | 20 | 1 | 950 | 19 | 2 | 900 | 18 |
Solution
Prey.h:
Predator.h:


