Points - // Draws many points with those on the left half...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // Points.java Author: Lewis and Loftus // // Solution to Programming Project 3.28 //******************************************************************** / import javax.swing.JApplet; import java.awt.*; import java.util.Random; i public class Points extends JApplet { private final int APPLET_WIDTH = 300; private final int APPLET_HEIGHT = 200; private final int NUM_POINTS = 20000; private Random rand = new Random(); //-----------------------------------------------------------------
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Draws many points with those on the left half in red and // those on the right half in green. //-----------------------------------------------------------------public void paint (Graphics page) { int x, y; setBackground (Color.black); for (int count=1; count <= NUM_POINTS; count++) { x = Math.abs(rand.nextInt()) % APPLET_WIDTH; y = Math.abs(rand.nextInt()) % APPLET_HEIGHT; if (x < APPLET_WIDTH/2) page.setColor (Color.red); else page.setColor (Color.green); page.drawLine (x, y, x, y); } } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online