37 lines
497 B
C#
37 lines
497 B
C#
|
namespace MindBox.Lib;
|
||
|
|
||
|
public class Circle : FlatShape
|
||
|
{
|
||
|
private readonly double _radius;
|
||
|
|
||
|
public required double Radius
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return _radius;
|
||
|
}
|
||
|
init
|
||
|
{
|
||
|
if (value <= 0.0)
|
||
|
{
|
||
|
throw new ArgumentException($"Radius cannot be non-positive: {value}");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_radius = value;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
public override double GetArea()
|
||
|
{
|
||
|
if (_area != null)
|
||
|
{
|
||
|
return _area.Value;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_area = Math.PI * _radius * _radius;
|
||
|
return _area.Value;
|
||
|
}
|
||
|
}
|
||
|
}
|