Ejemplo n.º 1
0
        private void MoveFoward()
        {
            var nextPosition = NextPositionIfMovedForward();

            if (IsOutOfBounds(nextPosition.X, nextPosition.Y))
            {
                if (!_mars.IsScented(X, Y))
                {
                    IsLost = true;
                    _mars.AddScentedCoordinate(X, Y);
                }
            }
            else
            {
                X = nextPosition.X;
                Y = nextPosition.Y;
            }
        }
Ejemplo n.º 2
0
        private void CautiouslyMoveFoward()
        {
            var nextPosition = NextPositionIfMovedForward();

            if (IsOutOfBounds(nextPosition.X, nextPosition.Y))
            {
                if (!_mars.IsScented(X, Y))
                {
                    IsLost = true;
                    _mars.AddScentedCoordinate(X, Y);
                }
                //ignore command if it is scented
            }
            else
            {
                X = nextPosition.X;
                Y = nextPosition.Y;
            }
        }