-
Notifications
You must be signed in to change notification settings - Fork 7
/
Circle.cs
46 lines (41 loc) · 1.09 KB
/
Circle.cs
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
38
39
40
41
42
43
44
45
46
using System;
namespace ExerciseSolution
{
/// <summary>
/// Represent a circle shape.
/// </summary>
public class Circle : Shape
{
/// <summary>
/// The radius of the shape.
/// </summary>
public float Radius
{
get { return radius; }
set
{
radius = value;
Area = calculateArea();
}
}
private float radius;
/// <summary>
/// Constructor. Creates a circle with the given radius.
/// </summary>
/// <param name="radius">the radius of this shape</param>
/// <param name="position">the position of this shape</param>
public Circle(float radius, Point2D position)
: base(position)
{
Radius = radius;
}
/// <summary>
/// Calculates the area of this circle.
/// </summary>
/// <returns>the area</returns>
protected override float calculateArea()
{
return (float)(Math.PI * Radius * Radius);
}
}
}