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

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

diff --git a/src/main/java/shape/tp5/Rectangle.java b/src/main/java/shape/tp5/Rectangle.java
new file mode 100644
index 0000000..a862169
--- /dev/null
+++ b/src/main/java/shape/tp5/Rectangle.java
@@ -0,0 +1,29 @@
+package shape.tp5;
+import javafx.scene.canvas.GraphicsContext;
+
+public class Rectangle implements Shape {
+    private double x, y, width, height;
+
+    public Rectangle(double x, double y, double width, double height) {
+        this.x = x;
+        this.y = y;
+        this.width = width;
+        this.height = height;
+    }
+
+    @Override
+    public void paint(GraphicsContext graphicsContext) {
+        graphicsContext.strokeRect(x, y, width, height);
+    }
+
+    @Override
+    public boolean contains(double px, double py) {
+        return px >= x && px <= x + width && py >= y && py <= y + height;
+    }
+
+    @Override
+    public void translate(double dx, double dy) {
+        this.x += dx;
+        this.y += dy;
+    }
+}
-- 
GitLab