using System;
class Rectangle
{
public double length=1;
public double width=1;
public void setLength(double x)
{
if((x>0)&&(x<20))
{
length=x;
}
}
public void setWidth(double y)
{
if((y>0)&&(y<20))
{
width=y;
}
}
public double getPerimeter()
{
Console.WriteLine ("面积是:");
return 2*length+2*width;
}
public double getArea()
{
Console.WriteLine ("周长是:");
return length*width;
}
}
class Test
{
static void Main()
{
Console.WriteLine("请输入第一个数:");
double i=double.Parse (Console.ReadLine ());
Console.WriteLine("请输入第二个数:");
double j=double.Parse (Console.ReadLine ());
Rectangle r=new Rectangle ();
r.setLength (i);
r.setWidth (j);
Console.WriteLine (r.getPerimeter ());
Console.WriteLine (r.getArea ());
Console.ReadLine ();
}
}
写的仓促, 如有不足,敬请谅解!!