Circle - { radius = Math.abs(generator.nextInt())%50 + 25;...

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

View Full Document Right Arrow Icon
// **************************************************************** // Circle.java // // Define a Circle class with methods to create and draw // a circle of random size, color, and location. // // **************************************************************** import java.awt.*; import java.util.Random; public class Circle { private int centerX, centerY; private int radius; private Color color; static Random generator = new Random(); //--------------------------------------------------------- // Creates a circle with center at point given, random radius and color // -- radius 25. .74 // -- color RGB value 0. .16777215 (24-bit) //--------------------------------------------------------- public Circle(Point point)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { radius = Math.abs(generator.nextInt())%50 + 25; color = new Color(Math.abs(generator.nextInt())% 16777216); centerX = point.x; centerY = point.y; } //---------------------------------------------------------// Draws circle on the graphics object given //---------------------------------------------------------public void draw(Graphics page) { page.setColor(color); page.fillOval(centerX-radius,centerY-radius,radius*2,radius*2); } //---------------------------------------------------------// Moves the circle to the given point. //---------------------------------------------------------public void move(Point p) { centerX = p.x; centerY = p.y; } }...
View Full Document

Ask a homework question - tutors are online