Ejemplo n.º 1
0
        public static LandingPlatform Create(ISize size, IPosition position, int platformRocketSeparation)
        {
            LandingPlatform landingPlatform = new LandingPlatform();

            landingPlatform.SetSize(size);
            landingPlatform.SetPlatformPosition(position);
            landingPlatform.SetPlatformRocketSeparation(platformRocketSeparation);
            return(landingPlatform);
        }
Ejemplo n.º 2
0
        public void AddLandingPlatform(LandingPlatform landingPlatform)
        {
            if (landingPlatform == null)
            {
                throw new ArgumentNullException(nameof(landingPlatform));
            }

            if (IsValidatePlatformPosition(landingPlatform))
            {
                _landingPlatform = landingPlatform;
            }
        }
Ejemplo n.º 3
0
        protected Landings(ISize landingAreaSize, ISize platformSize, IPosition platformPosition, int platformRocketSeparation)
        {
            if (landingAreaSize == null)
            {
                throw new ArgumentNullException(nameof(landingAreaSize));
            }

            if (platformSize == null)
            {
                throw new ArgumentNullException(nameof(platformSize));
            }

            _landingArea = LandingArea.Create(landingAreaSize);

            _landingArea.AddLandingPlatform(LandingPlatform.Create(platformSize, platformPosition, platformRocketSeparation));
        }
Ejemplo n.º 4
0
        private bool IsValidatePlatformPosition(LandingPlatform landingPlatform)
        {
            IPosition position = landingPlatform.PlatformPosition;
            var       cols     = Enumerable.Range(1, Size.X).ToList();
            var       rows     = Enumerable.Range(1, Size.Y).ToList();

            if (!cols.Contains(position.X) || !rows.Contains(position.Y))
            {
                throw new OutOfLandingAreaDomainException();
            }

            //Checking if the platform is inside of the landing area
            int maxPlatformCols = Enumerable.Range(position.X, landingPlatform.Size.X).Max();
            int maxPlatformRows = Enumerable.Range(position.Y, landingPlatform.Size.Y).Max();

            if (!cols.Contains(maxPlatformCols) || !rows.Contains(maxPlatformRows))
            {
                throw new OutOfLandingAreaDomainException();
            }

            return(true);
        }