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

to correct later

parent b29bdbe1
Branches
No related tags found
No related merge requests found
...@@ -7,17 +7,23 @@ import javafx.scene.paint.Color; ...@@ -7,17 +7,23 @@ import javafx.scene.paint.Color;
public class Circle implements Shape { public class Circle implements Shape {
private double radius, x, y; private double radius, x, y;
private Color fillColor;
public Circle(double x, double y, double radius) { public Circle(double x, double y, double radius) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.radius = radius; this.radius = radius;
this.fillColor = Color.GREEN;
} }
@Override @Override
public void paint(GraphicsContext graphicsContext) { 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); graphicsContext.strokeOval(x-radius, y-radius, 2 * radius, 2 * radius);
} }
...@@ -33,8 +39,17 @@ public class Circle implements Shape { ...@@ -33,8 +39,17 @@ public class Circle implements Shape {
this.x += dx; this.x += dx;
this.y += dy; this.y += dy;
} }
@Override
public boolean isFinished() {
return true;
}
public void updateRadius(double newX, double newY) { public void updateRadius(double newX, double newY) {
this.radius = Math.sqrt(Math.pow(newX - this.x, 2) + Math.pow(newY - this.y, 2)); 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{ ...@@ -36,6 +36,12 @@ public class Rectangle implements Shape{
x += dx; x += dx;
y += dy; y += dy;
} }
@Override
public boolean isFinished() {
return false;
}
public void updateSize(double newX, double newY) { public void updateSize(double newX, double newY) {
this.width = Math.abs(newX - this.x); this.width = Math.abs(newX - this.x);
this.height = Math.abs(newY - this.y); this.height = Math.abs(newY - this.y);
......
...@@ -7,4 +7,5 @@ public interface Shape { ...@@ -7,4 +7,5 @@ public interface Shape {
void paint(GraphicsContext graphicsContext); void paint(GraphicsContext graphicsContext);
boolean contains(double x, double y); boolean contains(double x, double y);
void translate(double dx, double dy); 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