class Rec{
private int length;
private int high;
Rec(){}
Rec(int length,int high){
this.length = length;
this.high = high;
}
public int getLength(){
return length;
}
public void setLength(int length){
this.length = length;
}
public int getHigh(){
return high;
}
public void setHigh(int high){
this.high = high;
}
//面积
public void area(){
System.out.println("Area="+length*high);
}
//体积
public void perimeter(){
System.out.println("Perimeter="+2*(length+high));
}
}
|
|