package shape; import javafx.geometry.Point2D; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; public class Rectangle implements Shape{ private double x; private double y; private double width; private double height; public Rectangle(double x, double y, double width, double height) { this.x = x; this.y = y; this.width = width; this.height = height; } @Override public void paint(GraphicsContext graphicsContext) { graphicsContext.strokeRect(x, y, width, height); } @Override public boolean contains(double x, double y) { return x>= this.x && x<= this.x + this.width && y>= this.y && y<= this.y + this.height; } @Override public void translate(double dx, double dy) { x += dx; y += dy; } }