Skip to content
Snippets Groups Projects
Commit ab0af32f authored by AREZKI Celia's avatar AREZKI Celia
Browse files

add circle class that manages the shapes

parent d4ee9a21
No related branches found
No related tags found
No related merge requests found
package shape.tp5;
import javafx.scene.canvas.GraphicsContext;
public class Circle implements Shape {
private double x, y, radius;
public Circle(double x, double y, double radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
@Override
public void paint(GraphicsContext graphicsContext) {
graphicsContext.strokeOval(x - radius, y - radius, radius * 2, radius * 2);
}
@Override
public boolean contains(double x, double y) {
double dx = x - this.x;
double dy = y - this.y;
return dx * dx + dy * dy <= radius * radius;
}
@Override
public void translate(double dx, double dy) {
this.x += dx;
this.y += dy;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment