设计一个名为Rectangle的类表示矩形。这个类包括: 两个名为width和height的int型数据域,它们分别表示矩形的宽和高。width和height的默认值都为10. 一个无参构造方法。 一个为width和height指定值的矩形构造方法。 一个名为getArea()的方法返回这个矩形的面积。 一个名为getPerimeter()的方法返回这个矩形的周长。。
class Rectangle{
private int width = 10;
private int heigth = 10;
public Rectangle() {
}
public Rectangle(int width, int heigth)
{
this.width = width;
this.heigth = heigth;
}
public int getArea()
{
return this.width * this.heigth;
}
public int getPerimeter()
{
return this.heigth*2 + this.width*2;
}
}