FileDocCategorySizeDatePackage
Circles.javaAPI DocExample958Wed Oct 04 14:10:32 BST 2000None

Circles

public class Circles extends Applet

Fields Summary
private int
counter
private int
stopValue
private int
xCoord
private int
yCoord
int
diameter
final int
change
Constructors Summary
Methods Summary
public voidpaint(java.awt.Graphics g)

	
	   
	
		int numCircles;
		stopValue = 1;
		counter = (int)(Math.random() * 15 + 1);
		numCircles = counter;
		xCoord = xCoord - counter * (change / 2);
		yCoord = yCoord - counter * (change / 2);
		while (counter >= stopValue)
		{
			diameter = counter * change;

		   if (counter % 2 == 0)
		   {
		   	g.setColor(Color.blue);
			}
			else
			{
				g.setColor(Color.red);
			}
			g.fillOval(xCoord, yCoord, diameter, diameter);
			counter = counter - 1;
			xCoord = xCoord + change / 2;
			yCoord = yCoord + change / 2;
		}
		g.drawString(numCircles + " Nice circles", change, counter * diameter + change);