From 61a4fe90b89cc127444405597a2590f8537474e5 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Mon, 13 Nov 2023 22:40:23 +0300 Subject: Initial commit --- MindBox.Lib/Circle.cs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 MindBox.Lib/Circle.cs (limited to 'MindBox.Lib/Circle.cs') diff --git a/MindBox.Lib/Circle.cs b/MindBox.Lib/Circle.cs new file mode 100644 index 0000000..5793a26 --- /dev/null +++ b/MindBox.Lib/Circle.cs @@ -0,0 +1,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; + } + } +} \ No newline at end of file -- cgit v1.2.3