FileDocCategorySizeDatePackage
lotteryNos.javaAPI DocExample1597Thu Mar 22 11:48:00 GMT 2001None

lotteryNos.java

import java.awt.*;		// make the graphics libraries available
import java.applet.*;	// make the applet libraries available
import java.util.*;		// make the random number library available
								// The random number generator returns a value
								// in the range 0.00 - 0.999. We need to convert this
								// into an integer value in the range 1 - 49

// Create an applet, generate and display a set of lottery numbers

public class LotteryNos extends Applet // make a new applet
{
	private int lotteryNumber;		// to hold the value of a random number
	private int circleXPosition ; // position of circle
	private int circleYPosition ;
	private int textXPosition ;	// positon of text
	private int textYPosition ;
	
	public void paint(Graphics g)
	{
		circleXPosition = 1 ;	// set position of first circle
		circleYPosition = 20 ;
		textXPosition = 12 ;		// set position of text
		textYPosition = 42 ;
	
		// define and int, count, and initialise it to 1. Repeat the for 
		// loop until count = 7, and increment count by one for each time
		// round the loop.	
	
		// for loop in here
		{
			lotteryNumber  = (int) (Math.random() * 49) + 1; // get a value for the lottery number
	
			// draw a circle in which to display the lottery number
			g.setColor(Color.blue) ;
			g.drawOval(circleXPosition,circleYPosition,33,33) ;
			
			// write the lottery number
			g.setColor(Color.red);
			g.drawString("" + lotteryNumber, textXPosition, textYPosition);
			
			// increment position coordinates

			// position increment code here	
	
		}
		
	}
}