Newer
Older
package shape;
import javafx.geometry.Point2D;
import javafx.scene.canvas.GraphicsContext;
public class Circle implements Shape {
private double radius, x, y;
public Circle(double x, double y, double radius) {
this.x = x;
this.y = y;
this.radius = radius;
public void paint(GraphicsContext graphicsContext) {
graphicsContext.strokeOval(x-radius, y-radius, 2 * radius, 2 * radius);
public boolean contains(double x, double y) {
double dx = x -= this.x;
double dy = y -= this.y;
return dx*dx + dy*dy <= radius*radius;
public void translate(double dx, double dy) {
this.x += dx;
this.y += dy;