aboutsummaryrefslogtreecommitdiff
path: root/MindBox.Lib/Circle.cs
blob: 5793a26bac15c6af2c96d80b727e2f17806ee917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
		}
	}
}