...宽(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()));
}
}