Exemplo n.º 1
0
        public override int GetHashCode()
        {
            var hashCode = 999451561;

            hashCode = hashCode * -1521134295 + SideA.GetHashCode();
            hashCode = hashCode * -1521134295 + SideB.GetHashCode();
            return(hashCode);
        }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            int prime = 37;
            int hash  = 1;

            hash = prime * hash + SideA.GetHashCode();
            hash = prime * hash + SideB.GetHashCode();
            return(hash);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Define weather the triangle is isisceles
 /// </summary>
 /// <returns>True, if triangle is isisceles</returns>
 public bool IsIsosceles()
 {
     if (SideA.Equals(SideB) && !SideA.Equals(SideC) ||
         SideA.Equals(SideC) && !SideA.Equals(SideB) ||
         SideC.Equals(SideB) && !SideA.Equals(SideC))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Define weather the triangle is right
 /// </summary>
 /// <returns>True, if triangle is right</returns>
 public bool IsRight()
 {
     if (SideA.Equals(Math.Pow(SideB * SideB + SideC * SideC, 0.5)) ||
         SideB.Equals(Math.Pow(SideA * SideA + SideC * SideC, 0.5)) ||
         SideC.Equals(Math.Pow(SideB * SideB + SideA * SideA, 0.5)))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Compare two triangles
        /// </summary>
        /// <param name="other">Second triangle</param>
        /// <returns>True, if triangles are equal</returns>
        public bool Equals(Triangle other)
        {
            ChekRefOnNull(this);
            ChekRefOnNull(other);

            if (SideA.Equals(SideB) && SideA.Equals(SideC))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
 // The ClearButton_Click Method
 // purpose: Clear the textboxes, and put the cursor back in the first text box
 // Parameters: The sending object, and the event arguments
 // Returns: none
 private void ClearButton_Click(object sender, EventArgs e)
 {
     // clear each text box.
     SideA.Clear();
     SideB.Clear();
     AngleC.Clear();
     SideC.Clear();
     AngleA.Clear();
     AngleB.Clear();
     // put the cursor back in the first text box.
     SideA.Select();
 }
Exemplo n.º 7
0
        //функция проверки на правильность. в ходе проверки выясняется, какие из сторон - катеты, какие - гипотенузы. чтобы не повторять эти процедуры - функция выписывает катеты и гипотенузу во внешние переменные
        public bool IsRightTriangle(out T CathetAOut, out T CathetBOut, out T HypotenuseOut)
        {
            T hypotenuse, cathet1, cathet2;

            if (SideA.CompareTo(SideB) == 1)
            {
                hypotenuse = SideA;
                cathet1    = SideB;
            }
            else
            {
                cathet1    = SideA;
                hypotenuse = SideB;
            }
            if (hypotenuse.CompareTo(SideC) == 1)
            {
                cathet2 = SideC;
            }
            else
            {
                cathet2    = hypotenuse;
                hypotenuse = SideC;
            }
            try
            {
                if (((dynamic)cathet2 * (dynamic)cathet2 + (dynamic)cathet1 * (dynamic)cathet1) == (dynamic)hypotenuse * (dynamic)hypotenuse)
                {
                    CathetAOut    = cathet1;
                    CathetBOut    = cathet2;
                    HypotenuseOut = hypotenuse;
                    return(true);
                }

                else
                {
                    CathetAOut    = default(T);
                    CathetBOut    = default(T);
                    HypotenuseOut = default(T);
                    return(false);
                }
            }
            catch
            {
                CathetAOut    = default(T);
                CathetBOut    = default(T);
                HypotenuseOut = default(T);
                ErrorLog("Type Error! Sides cannot be this types");
                return(false);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Determines whether the specified object is equal to the current object.
        /// </summary>
        /// <param name="obj"> The object to compare with the current object.</param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Triangle tr = obj as Triangle;

            if (tr == null)
            {
                return(false);
            }

            return(SideA.Equals(tr.SideA) && SideB.Equals(tr.SideB) && SideC.Equals(tr.SideC));
        }
Exemplo n.º 9
0
        //функция проеврки треугольника на правильность для тестов
        public bool IsRightTriangle()
        {
            T hypotenuse, cathet1, cathet2;

            if (SideA.CompareTo(SideB) == 1)
            {
                hypotenuse = SideA;
                cathet1    = SideB;
            }
            else
            {
                cathet1    = SideA;
                hypotenuse = SideB;
            }
            if (hypotenuse.CompareTo(SideC) == 1)
            {
                cathet2 = SideC;
            }
            else
            {
                cathet2    = hypotenuse;
                hypotenuse = SideC;
            }
            try
            {
                if (((dynamic)cathet2 * (dynamic)cathet2 + (dynamic)cathet1 * (dynamic)cathet1) == (dynamic)hypotenuse * (dynamic)hypotenuse)
                {
                    return(true);
                }

                else
                {
                    return(false);
                }
            }
            catch
            {
                ErrorLog("Type Error! Sides cannot be this types");
                return(false);
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            float  SideA;
            float  SideB;
            string input;
            float  RectArea;

            Console.WriteLine("How long is side A?");
            input = Console.ReadLine();
            SideA = float.Parse(input);
            Console.WriteLine("\nHow long is side B?");
            input = Console.ReadLine();
            SideB = float.Parse(input);

            RectArea = SideA * SideB;

            Console.WriteLine("\nYou entered " + SideA.ToString() + " units for side A and "
                              + SideB.ToString() + " units for side B.");
            Console.WriteLine("\nThe area of the rectangle is " + RectArea.ToString() + " units squared");
            Console.ReadLine();
        }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(SideA.GetHashCode() ^ SideB.GetHashCode() ^ SideC.GetHashCode() ^ AngleA.GetHashCode() ^ AngleB.GetHashCode() ^ AngleC.GetHashCode());
 }
Exemplo n.º 12
0
 public override int GetHashCode()
 {
     return(SideA.GetHashCode() + SideB.GetHashCode());
 }
Exemplo n.º 13
0
 /// <summary>
 /// Define weather the triangle is equilateral
 /// </summary>
 /// <returns>True, if triangle is equilateral</returns>
 public bool IsEquilateral()
 {
     return(SideA.Equals(SideB) && SideA.Equals(SideC) ? true : false);
 }
 public bool IsRightTriangle()
 {
     return(SideA.Equals(Math.Sqrt(Math.Pow(SideB, 2) + Math.Pow(SideC, 2))) ||
            SideB.Equals(Math.Sqrt(Math.Pow(SideA, 2) + Math.Pow(SideC, 2))) ||
            SideC.Equals(Math.Sqrt(Math.Pow(SideA, 2) + Math.Pow(SideB, 2))));
 }
Exemplo n.º 15
0
 public override string ToString()
 {
     return(SideA.ToString() + "-" + SideB.ToString());
 }
Exemplo n.º 16
0
 /// <summary>
 /// Get a hash code for the current object.
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(3 * SideA.GetHashCode() + 2 * SideB.GetHashCode() -
            2 * SideC.GetHashCode());
 }