Exemplo n.º 1
0
        public double GetCalculationAreaResult(List <Point> points)
        {
            var pointsValidationResult = new PointsValidationResult();

            pointsValidationResult = PointsValidator.GetPointsValidationResult(points);
            if (!pointsValidationResult.IsPointsValid)
            {
                return(-1);
            }
            else
            {
                Logger.Info($"[{this.GetType().Name}]: Calculating area of input points");
                double resultX = CalculateArea(points, true);
                double resultY = CalculateArea(points, false);
                if (resultX == resultY)
                {
                    Logger.Info($"[{this.GetType().Name}]: Square of area is " + resultX);
                    return(resultX);
                }
                else
                {
                    Logger.Error($"[{this.GetType().Name}]: The result of calculating area is incorrect. ");
                    return(0);
                }
            }
        }
Exemplo n.º 2
0
        public EarthCalculationResult GetEarthCalculationResult(IList <Point> points)
        {
            var earthCalculationResult = new EarthCalculationResult();

            earthCalculationResult.PointsValidationResult = PointsValidator.GetPointsValidationResult(points);
            bool isPointsValid = earthCalculationResult.PointsValidationResult.IsPointsValid;

            if (isPointsValid)
            {
                double result            = CalculateEarthSquare(points);
                double alternativeResult = CalculateEarthSquare(points, true);
                earthCalculationResult.IsCalculationSuccess = result == alternativeResult;
                earthCalculationResult.EarthSquare          = earthCalculationResult.IsCalculationSuccess? result : -1;
            }
            else
            {
                earthCalculationResult.EarthSquare          = -1;
                earthCalculationResult.IsCalculationSuccess = isPointsValid;
            }

            return(earthCalculationResult);
        }