dH = a*H - alpha*HPThese equations have 2 variables (H, and P) and 4 constants (a, b, alpha, and, beta). H is the number of herbavores, P, the number of predators, a is the birth rate for herbavores, b the death rate for predators, alpha is the proportion of Hs eaten by Ps, and beta is the proportion of eaten herbavores that are converted to new predators. dH means the change in H (in one time step), dP, the change in P.
dP = beta*H*P - b*P
This lab will display the output of the LV equations as a graph. Allow the user to select the initial H and P values with Scrollbars (and a, b, alpha, and beta, if you are feeling strong). Whenever they choose a new value, redraw the graph (so they can see what they are doing). You will need to decide how many steps you will simulate; for starters, 10 or 100 would be fine.
You have a prototype Grapher (from Lab 4) that stores values entered by the user in an ArrayList<Integer>. For this lab use the values generated by the LV equations to generate that list. Start by only displaying the H values.
You can no longer assume all values are between 0 and 100; instead, before plotting any points, you must find the maximum value to be plotted and scale all the values by that.
int x = left;
for (Integer nextInt: list) {
x += width/10; // to move over 1/10 the width
int y = bottom - nextInt.intValue()*width/100;
GraphCircle theCircle = new GraphCircle();
theCircle.setX(x);
theCircle.setY(y);
theCircle.paint(g);
}
you could change the 100 (which was the maximum allowable value) to max (which is the
maximum value of the H's in the list); similarily, the 10 should be the number of points you
are plotting (beware! if the number of points is more than width the points will all be on
the axis ('cuz of that pesky int division!)).
void drawPoints(Graphics g) {
drawHs(g);
drawPs(g);
}
It would be nice to draw H's in one color and P's in another.
You can either scale them both the same, or scale both to fill the graph vertically (the second looks
better, but is a bit more complicated).