Follow these steps:
• First, make a new class in your project, called Mandelbrot. Then copy the
source for your annulus program into the new class, and edit it to change the
name of the class to Mandelbrot.
• Add a new constant, MAX_STEPS = 255
• Remove the code that asks the user for the dimensions of the annulus
• Set MINX = -2, MAXX= 2, MINY = -2, MAXY = 2
• Next, find the place in your code where you test whether or not (x,y) is on the
shape, and replace it with this code:
boolean inside = true;
int steps = 0;
double px = 0;
double py = 0;
while(steps < MAX_STEPS && inside)
{
inside = px*px + py*py < 4.0;
double py1 = 2*px*py + y;
px = px*px - py*py + x;
py = py1;
steps++;
}
• Change your code to use the value of inside to decide whether to increment
the hit count for the cell.