public class Rectangle
{
private double width, height;
public Rectangle()
{
this(0, 0);
}
public Rectangle(double width, double height)
{
this.width = width;
this.height = height;
}
public double getCurve()
{
return 2.0f * (width + height);
}
public double getSurface()
{
return width * height;
}
}
public class Test
{
public static void main(String[] args)
{
Rectangle rect1 = new Rectangle(10, 20);
System.out.println("面积:" + rect1.getSurface());
System.out.println("周长:" + rect1.getCurve());
}
}