Exemplo n.º 1
0
 /// <summary>
 /// Constructor with a <paramref name="rightTriangle"/>.
 /// </summary>
 /// <param name="rightTriangle">the right triangle.</param>
 public Triangle(RightTriangle rightTriangle)
 {
     _sideA  = rightTriangle.Length;
     _sideB  = rightTriangle.Height;
     _sideC  = Pythagorean.FindHypotenuse(_sideA, _sideB);
     _angleC = 90;
     _angleB = Math.Atan(_sideB / _sideA);
     _angleA = _angleB - 90;
 }
Exemplo n.º 2
0
 /// <summary>
 /// </summary>
 /// <param name="rightTriangle"></param>
 /// <exception cref="ArgumentOutOfRangeException">Thrown when invalid side lengths are input</exception>
 public Triangle(RightTriangle rightTriangle)
 {
     _sideA = rightTriangle.Length;
     _sideB = rightTriangle.Height;
     _sideC = Pythagorean.FindHypotenuse(_sideA, _sideB);
     _angleC = 90;
     _angleB = Math.Atan(_sideB / _sideA);
     _angleA = _angleB - 90;
 }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(RightTriangle other)
 {
     return(other != null && (Math.Abs(_length - other._length) < 1 && Math.Abs(_height - other._height) < 1));
 }
Exemplo n.º 4
0
        public void TriangleTest()
        {
            Triangle triangle = new Triangle(length:5, height:6);

            Assert.AreEqual(5, triangle.SideA);
            Assert.AreEqual(6, triangle.SideB);
            Assert.AreEqual(15, triangle.Area);

            RightTriangle triangle2 = new RightTriangle(5, 6);

            Assert.AreEqual(triangle, triangle2);
            Assert.AreEqual(triangle.Perimeter, triangle2.Perimeter);

            Triangle triangle3 = new Triangle(sideB:4,sideC:5,angleC:90);
            Assert.AreEqual(triangle3.Area, 6);
            Assert.AreEqual(12, triangle3.Perimeter);
            Triangle triangle4 = new Triangle(sideB: 3, sideC: 3, angleC: 60);
            Assert.AreEqual(9, triangle4.Perimeter);

            /*
            try
            {
                Triangle wrongTriangle = new Triangle(1,6,10);
                Assert.Fail("This triangle should've thrown an exception!");
            }
            catch (Mathos.Exceptions.InvalidTriangleException)
            {
            }
             */
        }
Exemplo n.º 5
0
        public void RightTriangleTest()
        {
            RightTriangle triangle = new RightTriangle(5, 6);

            Assert.AreEqual(5, triangle.Length);
            Assert.AreEqual(6, triangle.Height);
            Assert.AreEqual(15, triangle.Area);

            RightTriangle triangle2 = new RightTriangle(5, 6);

            Assert.AreEqual(triangle, triangle2);

            RightTriangle triangle3 = new RightTriangle(3,4);
            Assert.AreEqual(12, triangle3.Perimeter);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(RightTriangle other)
 {
     return other != null && (Math.Abs(_length - other._length) < 1 && Math.Abs(_height - other._height) < 1);
 }