30
1
using System;
2
3
public class Program
4
{
5
public interface IShape {
6
void Draw();
7
double Area();
8
}
9
10
class Circle : IShape {
11
public double Radius { get; set; }
12
13
public Circle(double radius) {
14
Radius = radius;
15
}
16
17
public void Draw() {
18
// draw a circle!
19
}
20
public double Area() {
21
return Math.PI * Math.Pow(Radius, 2);
22
}
23
}
24
25
public static void Main() {
26
IShape c = new Circle(5);
27
Console.WriteLine(c.Area());
28
// 78.5398163397448
29
}
30
}
Cached Result
Doggo has 4 legs.
Woof!
Woof!