From ab0af32f7a0d62b45129fa5fca2527fb2ac7f2df Mon Sep 17 00:00:00 2001
From: a23022716 <celia.arezki.1@etu.univ-amu.fr>
Date: Fri, 11 Oct 2024 10:56:05 +0200
Subject: [PATCH] add circle class that manages the shapes

---
 src/main/java/shape/tp5/Circle.java | 30 +++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 src/main/java/shape/tp5/Circle.java

diff --git a/src/main/java/shape/tp5/Circle.java b/src/main/java/shape/tp5/Circle.java
new file mode 100644
index 0000000..22c61f8
--- /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;
+    }
+}
-- 
GitLab