Example #1
0
        public void MoveForward()
        {
            int x = this.Position.X;
            int y = this.Position.Y;

            switch (Direction)
            {
            case Direction.North:
                y++;
                break;

            case Direction.East:
                x++;
                break;

            case Direction.South:
                y--;
                break;

            case Direction.West:
                x--;
                break;

            default:
                throw new ArgumentOutOfRangeException("Invalid value set for Direction enum");
            }

            Position nextPosition = planet.CalculateOutOfBoundaryPosition(new Position(x, y));

            ThrowIfPositionNotClear(nextPosition);
            this.Position = nextPosition;
        }