public ApproachCheckResult CheckApproach(Guid rocketId, IPosition position, IDimension platformDimension)
        {
            if (position is null)
            {
                throw new ArgumentNullException(nameof(position));
            }

            if (platformDimension is null)
            {
                throw new ArgumentNullException(nameof(platformDimension));
            }

            ApproachCheckResult approachCheckResult;

            if (!platformDimension.Contains(position))
            {
                approachCheckResult = ApproachCheckResult.Out;
            }
            else if (IsPositionAlreadyChecked(rocketId, position) || IsCloseOfAnotherRocket(rocketId, position))
            {
                approachCheckResult = ApproachCheckResult.Clash;
            }
            else
            {
                approachCheckResult = ApproachCheckResult.Ok;
                UpdateCheckedPositions(rocketId, position);
            }

            return(approachCheckResult);
        }
Beispiel #2
0
        public LandingArea(IDimension areaDimension, ILandingPlatform platform, IApproachCheckResultMapper approachCheckResultMapper)
        {
            if (areaDimension is null)
            {
                throw new ArgumentNullException(nameof(areaDimension));
            }

            _platform =
                platform
                ?? throw new ArgumentNullException(nameof(platform));

            _approachCheckResultMapper =
                approachCheckResultMapper
                ?? throw new ArgumentNullException(nameof(approachCheckResultMapper));

            var platformDimension = platform.GetDimension();

            if (!areaDimension.Contains(platformDimension))
            {
                throw new ArgumentOutOfRangeException(nameof(platformDimension));
            }
        }