diff --git a/src/main/java/shape/tp5/Circle.java b/src/main/java/shape/tp5/Circle.java new file mode 100644 index 0000000000000000000000000000000000000000..22c61f87c163643314339e5621d0e3af12eb18c3 --- /dev/null +++ b/src/main/java/shape/tp5/Circle.java @@ -0,0 +1,30 @@ +package shape.tp5; +import javafx.scene.canvas.GraphicsContext; + +public class Circle implements Shape { + private double x, y, radius; + + public Circle(double x, double y, double radius) { + this.x = x; + this.y = y; + this.radius = radius; + } + + @Override + public void paint(GraphicsContext graphicsContext) { + graphicsContext.strokeOval(x - radius, y - radius, radius * 2, radius * 2); + } + + @Override + public boolean contains(double x, double y) { + double dx = x - this.x; + double dy = y - this.y; + return dx * dx + dy * dy <= radius * radius; + } + + @Override + public void translate(double dx, double dy) { + this.x += dx; + this.y += dy; + } +}