Exemple #1
0
        /// <summary>
        /// Checks if Three <see cref="ColorSide"/>s complete a <see cref="Triangle"/>.
        /// </summary>
        /// <param name="sideA">Represent First <see cref="Triangle"/> <see cref="ColorSide"/> will be checked.</param>
        /// <param name="sideB">Represent Second <see cref="Triangle"/> <see cref="ColorSide"/> will be checked.</param>
        /// <param name="sideC">Represent Third <see cref="Triangle"/> <see cref="ColorSide"/> will be checked.</param>
        /// <returns>True is <see cref="ColorSide"/>s complete <see cref="Triangle"/></returns>
        private static bool IsTriang(ColorSide sideA, ColorSide sideB, ColorSide sideC)
        {
            if (sideA.Length + sideB.Length <= sideC.Length ||
                sideA.Length + sideC.Length <= sideB.Length ||
                sideB.Length + sideC.Length <= sideA.Length)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Sets All Three <see cref="ColorSide"/>s of <see cref="Triangle"/>.
        /// </summary>
        /// <param name="sideA">Represent First <see cref="Triangle"/> <see cref="ColorSide"/> will be set.</param>
        /// <param name="sideB">Represent Second <see cref="Triangle"/> <see cref="ColorSide"/> will be set.</param>
        /// <param name="sideC">Represent Third <see cref="Triangle"/> <see cref="ColorSide"/> will be set.</param>
        public void SetSides(ColorSide sideA, ColorSide sideB, ColorSide sideC)
        {
            if (IsTriang(sideA, sideB, sideC) == false)
            {
                throw new ArgumentException("Transmitted sides can not make a triangle");
            }

            this.sides[0] = sideA;
            this.sides[1] = sideB;
            this.sides[2] = sideC;
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Triangle" /> class and sets all it Three <see cref="ColorSide"/>.
 /// </summary>
 /// <param name="sideA">Represent First <see cref="Triangle"/> <see cref="ColorSide"/> will be set.</param>
 /// <param name="sideB">Represent Second <see cref="Triangle"/> <see cref="ColorSide"/> will be set.</param>
 /// <param name="sideC">Represent Third <see cref="Triangle"/> <see cref="ColorSide"/> will be set.</param>
 /// <exception cref="ArgumentException">Invalid Argument.</exception>
 public Triangle(ColorSide sideA, ColorSide sideB, ColorSide sideC)
 {
     try
     {
         this.sides = new ColorSide[3];
         this.SetSides(sideA, sideB, sideC);
     }
     catch (Exception)
     {
         throw;
     }
 }