double lenght;
double widht;
void getArea(double lenght,double width){
double count=lenght*width;
System.out.println("面积为"+count);
}
void getPer(double lenght,double width){
double count=(lenght+width)*2;
System.out.println("周长为"+count);
}
void showAll(double lenght,double width){
double count=(lenght+width)*2;
double count1=lenght*width;
System.out.println("长为"+lenght);
System.out.println("宽长为"+width);
System.out.println("周长为"+count);
System.out.println("面积为"+count1);
}
测试
Rectangle r=new Rectangle();
r.lenght=20;
r.widht=30;
r.getArea(r.lenght,r.widht);
r.getPer(r.lenght,r.widht);
r.showAll(r.lenght,r.widht);