class zuoye{
public static void main (String []args){
Rectangle r = new Rectangle(10,20);
System.out.println(r.getlength());
System.out.println(r.getarea());
}
}
class Rectangle {
private int width;
private int high;
public Rectangle(){}
public Rectangle(int width, int high){
this.width = width;
this.high = high;
}
public void setWidth(int Width){
this.width = width;
}
public int getwidth(){
return width;
}
public void sethigh(int high){
this.high = high;
}
public int gethigh(){
return high;
}
public int getlength(){
return 2 * (width + high);
}
public int getarea(){
return width * high;
} |
|