class Test_Rectangle {
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;
private int length;
private int area;
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;
}
} |
|