1 回答
yanrun
TA贡献317条经验 获得超240个赞
public class Rectangle { private double length; private double width; public Rectangle(double length, double width) { this.length = length; this.width = width; } public double getArea() { return this.length * this.width; } public double getPerimeter() { return (this.length + this.width) * 2; } public static void main(String[] args) { Rectangle r = new Rectangle(4, 3); System.out.println("面积为:" + r.getArea()); System.out.println("周长为:" + r.getPerimeter()); } }
添加回答
举报
0/150
提交
取消