From 0adea74d5acdbbee633246dd53fe54a843d18122 Mon Sep 17 00:00:00 2001 From: a23022716 <celia.arezki.1@etu.univ-amu.fr> Date: Fri, 27 Sep 2024 11:43:56 +0200 Subject: [PATCH] fix of The Circle class stores the center point and radius, and it implements the draw method to render the circle using JavaFX's GraphicsContext. --- src/main/java/shape/Circle.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/shape/Circle.java b/src/main/java/shape/Circle.java index 81d9175..d023831 100644 --- a/src/main/java/shape/Circle.java +++ b/src/main/java/shape/Circle.java @@ -2,24 +2,36 @@ package shape; import javafx.geometry.Point2D; import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Color; public class Circle implements Shape { + private Point2D center; + private double radius; + private Color color; - public Circle(double x, double y, double sqrt) { + public Circle(Color color, double x, double y, double radius) { + this.color = color; + this.center = new Point2D(x, y); + this.radius = radius; } @Override public int pointsCount() { - return 0; + return 1; // Un cercle n'a qu'un centre } @Override public Point2D point(int index) { - return null; + if (index == 0) { + return center; + } + throw new IndexOutOfBoundsException("Circle has only one center point."); } @Override public void draw(GraphicsContext context) { - + context.setStroke(color); + context.strokeOval(center.getX() - radius, center.getY() - radius, + radius * 2, radius * 2); } } -- GitLab