我写了抽象类Shape,和Rentangle(矩形),圆一样的写法就不多写了!!!
abstract class Shape
{
public Shape()
{
}
public Shape(double x,double y)
{
this.x = x;
this.y = y;
}
private double x;
public double X
{
get { return x; }
set { x = value; }
}
private double y;
public double Y
{
get { return y; }
set { y = value; }
}
public abstract double Area();
}
class Rentangle:Shape
{
public Rentangle(double x, double y)
{
base.X = x;
base.Y = y;
}
public override double Area()
{
return X * Y;
}
}