Exemple #1
0
        public void FindHypotenuseValidateInputs()
        {
            var error = false;

            try
            {
                // Make sure side 1 is valid
                Pythagorean.FindHypotenuse(0, 2);
                error = true;
            }
            catch
            {
                // ignored
            }

            try
            {
                // Make sure side 2 is valid
                Pythagorean.FindHypotenuse(2, 0);
                error = true;
            }
            catch
            {
                // ignored
            }

            Assert.IsFalse(error, "We should have thrown errors above");
        }
Exemple #2
0
        public void FindHypotenuse()
        {
            var hypotenuse = Pythagorean.FindHypotenuse(3, 4);

            // Using pythagorean theorem, this hypotenuse is 5
            Assert.AreEqual(5, hypotenuse);
        }
Exemple #3
0
        public void FindNonHypotenuse()
        {
            var side2 = Pythagorean.FindNonHypotenuse(3, 5);

            // Using pythagorean theorem, the other side should be 4
            Assert.AreEqual(4, side2);
        }
 /// <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;
 }
 /// <summary>
 /// Constructor with a <paramref name="length"/> and <paramref name="height"/>.
 /// </summary>
 /// <param name="length">The length.</param>
 /// <param name="height">The height.</param>
 public Triangle(double length, double height)
 {
     _sideA  = length;
     _sideB  = height;
     _sideC  = Pythagorean.FindHypotenuse(_sideA, _sideB);
     _angleC = 90;
     _angleB = Math.Atan(height / length);
     _angleA = _angleB - 90;
 }
        /// <summary>
        /// Constructor with a <paramref name="length"/> and <paramref name="height"/>.
        /// </summary>
        /// <param name="length">The length.</param>
        /// <param name="height">The height.</param>
        public RightTriangle(double length, double height)
        {
            _length = length < 0 ? 0 : length;
            _height = height < 0 ? 0 : height;

            if (_length > 0 && _height > 0)
            {
                Hypotenuse = Pythagorean.FindHypotenuse(_length, _height);
            }
        }
Exemple #7
0
        public void SumOfTwelve()
        {
            int          sum      = 12;
            IntegerTuple triplet  = Pythagorean.GetTripletWithSumOf(sum);
            List <int>   expected = new List <int> {
                3, 4, 5
            };

            List <int> actual = triplet.ToList();


            CollectionAssert.AreEqual(expected, actual);
        }
        public double CalculatePythagoreanTheorem(Pythagorean model)
        {
            _logger.LogInformation("***Beginning Pythagorean Theorem Info***");
            _logger.LogInformation($"Input A = {model.InputA}");
            _logger.LogInformation($"Input B = {model.InputB}");

            model.InputA = Math.Round(model.InputA, 2);
            model.InputB = Math.Round(model.InputB, 2);

            double cSquared = model.InputA * model.InputA + model.InputB * model.InputB;
            double output   = Math.Round(Math.Sqrt(cSquared), 2);

            _logger.LogInformation($"Output C = {model.OutputC}");
            _logger.LogInformation($"***Ending Pythagorean Theorem Info***");

            return(output);
        }
Exemple #9
0
 public IActionResult Pythagorean(Pythagorean model)
 {
     model.OutputC = _calculateService.CalculatePythagoreanTheorem(model);
     return(View(model));
 }
Exemple #10
0
        public IActionResult Pythagorean()
        {
            var model = new Pythagorean();

            return(View(model));
        }