FileDocCategorySizeDatePackage
Dice.javaAPI DocExample1000Tue Aug 15 11:50:58 BST 2000None

dice

public class dice extends Applet

Fields Summary
int
firstDice
int
secondDice
int
loopCount
Constructors Summary
Methods Summary
public voidpaint(java.awt.Graphics g)

		loopCount = 0;
		do
		{
			loopCount = loopCount + 1;
			g.drawString("Attempt number:...> " + loopCount, 100, 100);
			firstDice = (int)(Math.random() * 6 + 1);
			secondDice = (int)(Math.random() * 6 + 1);
			g.setColor(Color.magenta);
			g.fillRect(80, 120, 60, 60);
			g.setColor(Color.yellow);
			g.fillRect(160, 120, 60, 60);
			g.setColor(Color.blue);
			g.drawString("" + firstDice, 107, 153);
			g.drawString("" + secondDice, 187, 153);
			for (int count = 0; count < 1000; count++)
			{
				g.drawString("   ", 200, 100);
			}
		} while (firstDice != secondDice);
		g.drawString("Congratulations - you've won", 80, 200);