//定义一个图形类及其子类(三角形类和矩形类),分别计算其面积和周长。
package JAVA;
class Rectangle {
private int width;
private int length;
public Rectangle(int width,int length) {
super();
this.width = width;
this.length = length;
}
public int getPerimeter(){
return this.width *2 + this.length *2;
}//获得周长
public int getArea(){
return this.width * this.length;
}