搜索

...宽(width)两个属性,有成员函数计算矩形的面积。并构造一个Rectangle...

发布网友 发布时间:2024-10-23 05:37

我来回答

2个回答

热心网友 时间:2024-11-07 06:45

......

热心网友 时间:2024-11-07 06:54

public class Rectangle {
public double len;
public double width;
public double getArea(double len,double width){
return len*width;
}

public double getLen() {
return len;
}
public void setWidth(double len) {
this.len = len;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}

public static void main(String[] args) {
Rectangle r = new Rectangle(40, 10);
System.out.println(r.getArea(r.getLen(), r.getWidth()));
}

}

热心网友 时间:2024-11-07 06:47

......

热心网友 时间:2024-11-07 06:51

public class Rectangle {
public double len;
public double width;
public double getArea(double len,double width){
return len*width;
}

public double getLen() {
return len;
}
public void setWidth(double len) {
this.len = len;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}

public static void main(String[] args) {
Rectangle r = new Rectangle(40, 10);
System.out.println(r.getArea(r.getLen(), r.getWidth()));
}

}
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com
Top