From 3c147b0fe124fd47d7cbdb30268edd2bce624f6c Mon Sep 17 00:00:00 2001 From: celia <celia.arezki.1@etu.univ-amu.fr> Date: Thu, 3 Oct 2024 16:10:50 +0200 Subject: [PATCH] fix of circle class some changes --- src/main/java/shape/Circle.java | 16 +++++++--------- src/main/java/shape/Rectangle.java | 4 +--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/shape/Circle.java b/src/main/java/shape/Circle.java index 0bcb264..e52f467 100644 --- a/src/main/java/shape/Circle.java +++ b/src/main/java/shape/Circle.java @@ -1,37 +1,35 @@ 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(Color color, double x, double y, double radius) { - this.color = color; + + public Circle(double x, double y, double radius) { this.center = new Point2D(x, y); this.radius = radius; } @Override public int pointsCount() { + return 1; } @Override public Point2D point(int index) { + if (index == 0) { return center; + } else { + throw new IndexOutOfBoundsException("Un cercle n'a qu'un seul point central."); } - 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); + context.strokeOval(center.getX() - radius, center.getY() - radius, radius * 2, radius * 2); } } diff --git a/src/main/java/shape/Rectangle.java b/src/main/java/shape/Rectangle.java index 0b18ab3..5b9b48a 100644 --- a/src/main/java/shape/Rectangle.java +++ b/src/main/java/shape/Rectangle.java @@ -16,13 +16,11 @@ public class Rectangle implements Shape { @Override public int pointsCount() { - return 0; - return 2; // Un rectangle est défini par deux points + } @Override public Point2D point(int index) { - return null; if (index == 0) { return point0; } else if (index == 1) { -- GitLab