代码如下
package one;
public class TestRectangle {
public static void main(String[] args){
Rectangle zheng = new Rectangle();
zheng.height=20;
zheng.width=10;
int area = zheng.calArea();
System.out.println("周长为"+area);
int aree =zheng.calPefimeter();
System.out.println("面积为"+aree);
}
}
class Rectangle{
int height;
int width;
public int calArea(){
return 2*height + 2*width;
}
public int calPefimeter(){
return height * width;
}
}