代码:
public class AreaVolume {
public static void main (String args []) {
Shapes shape1 = new Shapes (1, 2);
Shapes shape2 = new Shapes (1);
Shapes shape3 = new Shapes (1, 2, 3);
}
}
class Shapes {
double length, width, height, radius;
public Shapes (double length, width) {
System.out.println ("您定义的形状是矩形,其面积为:" + area (length, width) + "。");
}
public Shapes (double radius) {
System.out.println ("您定义的形状是球体,其体积为:" + volume (radius) + "。");
}
public Shapes (double length, width, height) {
System.out.println ("您定义的形状是立方体,其体积为:" + volume (length, width, height) + "。");
}
public static double area (double length, width) {
double area = length * width;
return area;
}
public static double volume (double radius) {
double volume1 = 4/3 * 3.14 * radius*radius*radius;
return volume1;
}
public static double volume (double length, width, height) {
double volume2 = length * width * height;
return volume2;
}
}
编译错误:
AreaVolume.java:11: 需要 <标识符>
public Shapes (double length, width) {
^
AreaVolume.java:17: 需要 <标识符>
public Shapes (double length, width, height) {
^
AreaVolume.java:17: 需要 <标识符>
public Shapes (double length, width, height) {
^
AreaVolume.java:20: 需要 <标识符>
public static double area (double length, width) {
^
AreaVolume.java:28: 需要 <标识符>
public static double volume (double length, width, height) {
^
AreaVolume.java:28: 需要 <标识符>
public static double volume (double length, width, height) {
^
6 错误
加什么类型啊?求写一行代码
追答public Shapes (double length, double width) {