Skip to content
Snippets Groups Projects
Commit d0a4191d authored by MANSOUR Chadi's avatar MANSOUR Chadi
Browse files

to correct later

parent b29bdbe1
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
......@@ -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);
......
......@@ -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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment