public class Rectangle{
private int length;
private int width;
public void Rectangle(int length,int width)
{
this.length=length;
this.width=width;
}
public int getPerimeter()
{
return (length+width)*2;
}
public int getArea()
{
if(length<=50 && length>=10)
if(width<=50 && width>=10)
return length*width;
}
public void drawRect()
{
int i,j;
for(i=0;i<width;i++)
{
if(i=0 || i=width-1)
{
for(j=0;j<length;j++)
System.out.print("*");
}
else {
for(j=0;j<length;j++)
{
if(j=0 || j=length-1)
System.out.print("*");
esle
System.out.print(" ");
}
}
System.out.println();
}
}
public static void main()
{
Rectangle R1=new Rectangle(20,30);
Rectangle R2=new Rectangle(30,40);
System.out.println("周长:"+R1.getPerimeter());
System.out.println("面积"+R1.getArea());
System.out.println("周长:"+R2.getPerimeter());
System.out.println("面积"+R2.getArea());
R1.drawRect();
}
}