/// <summary> /// The triangle is right /// </summary> /// <returns></returns> private bool IsRight() { double hypotenuse = this.Hypotenuse; Legs legs = this.GetLegs; // for a triangle the following is right: c^2 = a^2 b^2 // have no Idea about accuracy of .net compution, but will use is for now. return(hypotenuse * hypotenuse == ((legs.LegA * legs.LegA) + (legs.LegB * legs.LegB))); }
/// <summary> /// Get area of the triangle /// </summary> /// <returns>Area of the triangle</returns> internal double GetArea() { // if the triangle is right if (this.IsRight()) { // in this case, the following is right: Area = 1/2 * A * B Legs legs = this.GetLegs; return(legs.LegA * legs.LegB / 2); } else { throw new NotImplementedException("The assembly supposed to support only right triangles"); } }