public override double GetSurface()
{
if (this.Width == null)
{
throw new InvalidOperationException("Rectangle's width is not provided!");
}
if (this.Height == null)
{
throw new InvalidOperationException("Rectangle's height is not provided!");
}
double surface = this.Width.Value * this.Height.Value;
return surface;
}
}
public static void Main() { Circle circle = new Circle(5); Console.WriteLine("I am a circle. " + "My perimeter is {0:f2}. My surface is {1:f2}.", circle.GetPerimeter(), circle.GetSurface()); Rectangle rect = new Rectangle(2, 3); Console.WriteLine("I am a rectangle. " + "My perimeter is {0:f2}. My surface is {1:f2}.", rect.GetPerimeter(), rect.GetSurface()); }