1: using System; 2: 3: class Triangle 4: { 5: public virtual double ComputeArea(int a, int b, int c) 6: { 7: // Heronian formula 8: double s = (a + b + c) / 2.0; 9: double dArea = Math.Sqrt(s*(s-a)*(s-b)*(s-c)); 10: return dArea; 11: } 12: } 13: 14: class RightAngledTriangle:Triangle 15: { 16: public override double ComputeArea(int a, int b, int c) 17: { 18: double dArea = a*b/2.0; 19: return dArea; 20: } 21: } 22: 23: class TriangleTestApp 24: { 25: public static void Main() 26: { 27: Triangle tri = new Triangle(); 28: Console.WriteLine(tri.ComputeArea(2, 5, 6)); 29: 30: RightAngledTriangle rat = new RightAngledTriangle(); 31: Console.WriteLine(rat.ComputeArea(3, 4, 5)); 32: } 33: }