import java.awt.Color; public class Rectangle { private int x; private int y; private int x2; private int y2; private int lineWidth; private Color color; public Rectangle(int x, int y, int width, int height, int lineWidth, Color color) { this.x = x; this.y = y; this.x2 = width + x; this.y2 = height + y; this.lineWidth = lineWidth; this.color = color; } public Rectangle(int x, int y, int width, int height, int lineWidth) { this(x, y, width, height, lineWidth, Color.BLACK); } public Rectangle(int x, int y, int width, int height) { this(x, y, width, height, 1); } public void draw(SimpleWindow w) { w.setLineWidth(lineWidth); w.setLineColor(color); w.moveTo(x, y); w.lineTo(x, y2); w.lineTo(x2, y2); w.lineTo(x2, y); w.lineTo(x, y); } public int getX2() { return x2; } public int getY2() { return y2; } }