From d0a4191d848138803271a3b29fdaa161dbca3e73 Mon Sep 17 00:00:00 2001 From: m19023837 <chadi.mansour@etu.univ-amu.fr> Date: Fri, 4 Oct 2024 12:15:31 +0200 Subject: [PATCH] to correct later --- src/main/java/shape/Circle.java | 17 ++++++++++++++++- src/main/java/shape/Rectangle.java | 6 ++++++ src/main/java/shape/Shape.java | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/shape/Circle.java b/src/main/java/shape/Circle.java index ab52746..2f7796e 100644 --- a/src/main/java/shape/Circle.java +++ b/src/main/java/shape/Circle.java @@ -7,17 +7,23 @@ import javafx.scene.paint.Color; public class Circle implements Shape { private double radius, x, y; + private Color fillColor; public Circle(double x, double y, double radius) { this.x = x; this.y = y; this.radius = radius; + this.fillColor = Color.GREEN; } @Override public void paint(GraphicsContext graphicsContext) { - graphicsContext.setStroke(Color.RED); + graphicsContext.setStroke(Color.BLACK); + if(isFinished) { + graphicsContext.setFill(Color.GREEN); + graphicsContext.fillOval(x - radius, y - radius, 2 * radius, 2 * radius); + } graphicsContext.strokeOval(x-radius, y-radius, 2 * radius, 2 * radius); } @@ -33,8 +39,17 @@ public class Circle implements Shape { this.x += dx; this.y += dy; } + + @Override + public boolean isFinished() { + return true; + } + public void updateRadius(double newX, double newY) { this.radius = Math.sqrt(Math.pow(newX - this.x, 2) + Math.pow(newY - this.y, 2)); } + public void setFillColor(Color fillColor) { + this.fillColor = fillColor; + } } diff --git a/src/main/java/shape/Rectangle.java b/src/main/java/shape/Rectangle.java index b896ba8..0a2f626 100644 --- a/src/main/java/shape/Rectangle.java +++ b/src/main/java/shape/Rectangle.java @@ -36,6 +36,12 @@ public class Rectangle implements Shape{ x += dx; y += dy; } + + @Override + public boolean isFinished() { + return false; + } + public void updateSize(double newX, double newY) { this.width = Math.abs(newX - this.x); this.height = Math.abs(newY - this.y); diff --git a/src/main/java/shape/Shape.java b/src/main/java/shape/Shape.java index f376617..66aaf02 100644 --- a/src/main/java/shape/Shape.java +++ b/src/main/java/shape/Shape.java @@ -7,4 +7,5 @@ public interface Shape { void paint(GraphicsContext graphicsContext); boolean contains(double x, double y); void translate(double dx, double dy); + boolean isFinished(); } -- GitLab