public class Rectangle {
double width, length;
double area, zhou;
Rectangle(double x) {
width = x;
length = x;
}
Rectangle(double w, double len) {
width = w;
length = len;
}
public double zhouRectangle() {
zhou = (width + length) * 2;
return zhou;
}
public double areaRectangle() {
area = width * length;
return area;
}
public static void main(String[] args) {
double c, s;
Rectangle Rectangle1 = new Rectangle(10, 20);
Rectangle Rectangle2 = new Rectangle(7);
c = Rectangle1.zhouRectangle();
s = Rectangle2.areaRectangle();
System.out.println("周长是:" + c);
System.out.println("面积是:" + s);
}
}
、