```java class Rectangle { double length; double width; public Rectangle(double length, double width) { this.length = length; this.width = width; } public double calculateArea() { return length * width; } } class Cuboid extends Rectangle { double height; public Cuboid(double length, double width, double height) { super(length, width); this.height = height; } public double calculateVolume() { return calculateArea() * height; } } public class Test { public static void main(String[] args) { double length = Double.parseDouble(args[0]); double width = Double.parseDouble(args[1]); double height = Double.parseDouble(args[2]); Cuboid cuboid = new Cuboid(length, width, height); System.out.println("这是体积计算:" + cuboid.calculateVolume()); System.out.println("这是底面积计算:" + cuboid.calculateArea()); System.out.println("另一种实例化方式:"); Rectangle rectangle = new Rectangle(length, width); System.out.println("这是底面积计算:" + rectangle.calculateArea()); System.out.println("这是体积计算:" + cuboid.calculateVolume()); } } ``` [2024-10-20 18:34:47 | AI写代码神器 | 306点数解答]