Archived
1
0
This repository has been archived on 2023-12-01. You can view files and clone it, but cannot push or open issues or pull requests.
Mindbox/MindBox.Lib/Circle.cs

37 lines
497 B
C#
Raw Normal View History

2023-11-13 22:40:23 +03:00
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;
}
}
}