Example #1
0
        static void Main(string[] args)
        {
            var triangle = new Triangle(6, 8, 10);
            Console.WriteLine(triangle.CanTriangleExist());
            Console.WriteLine(triangle.GetSquare());

            Console.ReadLine();
        }
Example #2
0
 /// <summary>
 /// Checks whether such triangle can exist
 /// </summary>
 /// <param name="triangle">Triangle to check</param>
 /// <returns></returns>
 public static bool CanTriangleExist(Triangle triangle)
 {
     if (triangle.SideA + triangle.SideB <= triangle.SideC)
     {
         return false;
     }
     if (triangle.SideA + triangle.SideC <= triangle.SideB)
     {
         return false;
     }
     if (triangle.SideB + triangle.SideC <= triangle.SideA)
     {
         return false;
     }
     return true;
 }
Example #3
0
        /// <summary>
        /// Calculates square of the triangle
        /// </summary>
        /// <param name="triangle">Triangle to calculate</param>
        /// <returns></returns>
        public static double GetSquare(Triangle triangle)
        {
            double p = triangle.Perimeter/2;

            return Sqrt(p*(p - triangle.SideA)*(p - triangle.SideB)*(p - triangle.SideC));
        }