public class Rectangle extends Shape{ private double length; private double width; public Rectangle(double length, double width) { if (length <= 0 || width <= 0) { throw new IllegalArgumentException("长和宽必须大于0"); } this.length = length; this.width = width; } @Override public double getArea() { return length * width; } @Override public String getShapeName() { return "长方形"; } public double getLength() { return length; } public double getWidth() { return width; } }