FileDocCategorySizeDatePackage
Radii.javaAPI DocExample1274Wed Aug 02 11:41:40 BST 2000None

Radii

public class Radii extends Applet

Fields Summary
private int
counter
private int
stopValue
private final int
x1Coord
private final int
y1Coord
private final int
x2Coord
Constructors Summary
Methods Summary
public voidpaint(java.awt.Graphics g)

	// declare and initialise x2Coord constant
	
	   
	
		stopValue = (int)(Math.random() * 20 + 1); // generate a random termination value
		counter = 1;						// initialise the loop control variable
		while (counter <= stopValue)			// loop 10 times
		{
			if (counter % 2 == 0)		// if counter is an even number
			{
				g.setColor(Color.blue); // set drawing colour blue
			}
			else								// this is an odd number
			{
				g.setColor(Color.red);  // set drawing colour red
			}
			g.drawLine(x1Coord, y1Coord, x2Coord, counter * 10);
			counter = counter + 1;		// increment the loop control variable
		}
		g.drawString(stopValue + " Nice lines", 20, 260);