diff options
author | Serghei Cebotari <serghei@cebotari.ru> | 2023-11-13 22:40:23 +0300 |
---|---|---|
committer | Serghei Cebotari <serghei@cebotari.ru> | 2023-11-13 22:40:23 +0300 |
commit | 61a4fe90b89cc127444405597a2590f8537474e5 (patch) | |
tree | 44bfa66169cba2a7f2b79d959bf762b5e9bdeaa2 /MindBox.Lib/Circle.cs |
Initial commit
Diffstat (limited to 'MindBox.Lib/Circle.cs')
-rw-r--r-- | MindBox.Lib/Circle.cs | 37 |
1 files changed, 37 insertions, 0 deletions
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 |