/** * @(#)Circle.java * * * @author * @version 1.00 - TopicsExpress



          

/** * @(#)Circle.java * * * @author * @version 1.00 2013/7/17 */ import java.awt.*; public class Circle { private int centerX, centerY, radius; private Color color; public Circle() { } public Circle(int x, int y, int r, Color c) { centerX = x; centerY = y; radius = r; color = c; } public void draw(Graphics g) { Color oldColor = g.getColor(); g.setColor(color); g.drawOval(centerX - radius, centerY - radius, radius * 2, radius *2); g.setColor(oldColor); } public void fill(Graphics g) { Color oldColor = g.getColor(); g.setColor(color); g.fillOval(centerX - radius, centerY - radius, radius *2, radius * 2); g.setColor(oldColor); } public boolean containsPoint(int x, int y) { int xSquared = (x - centerX) * (x - centerX); int ySquared = (y - centerY) * (y - centerY); int rSquared = radius * radius; return xSquared + ySquared - rSquared
Posted on: Wed, 17 Jul 2013 08:17:05 +0000

Trending Topics



Recently Viewed Topics




© 2015