import java.awt.Color; import java.util.Scanner; public class Rectangle { private double length; private double width; private Color color; public Rectangle() { this.length = 1; this.width = 1; this.color = Color.BLACK; } public Rectangle(double l, double w) { this.length = l; this.width = w; this.color = Color.RED; } public double getArea() { return this.length * this.width; } public double getPerimeter() { return (this.length + this.width) * 2; } /** * Sets the area to area and makes the shape a square * @param area the area to set */ public void setArea(double area) { this.length = Math.sqrt(area); this.width = Math.sqrt(area); } /* public void setArea(double length, double width) { this.area = width * length; } */ // the following methods is probably bad public void setAreaToThingFromSystemIn() { Scanner s = new Scanner(System.in); this.setArea(s.nextDouble()); } public void setDimensions(double length, double w) { this.length = length; this.width = w; } public boolean isLargerThan(Rectangle that) { return this.getArea() > that.getArea(); } }