Esempio n. 1
0
        private List <char> TraverseToTheBottomAndReadPositions(TraversePath traversePath)
        {
            ResetCurrentPosition();
            var traversedTiles = new List <char>();

            while (!IsYPositionOutOfBound())
            {
                var currentTile = ReadCurrentPosition();
                traversedTiles.Add(currentTile);

                Traverse(traversePath);

                if (IsXPositionOutOfBound())
                {
                    WarpXPosition();
                }
            }

            return(traversedTiles);
        }
Esempio n. 2
0
 private void Traverse(TraversePath traversePath)
 {
     CurrentPosition.XPosition += traversePath.RightSteps;
     CurrentPosition.YPosition += traversePath.DownSteps;
 }
Esempio n. 3
0
        public int NumberOfTreesEncountered(TraversePath traversePath)
        {
            var traversedTiles = TraverseToTheBottomAndReadPositions(traversePath);

            return(traversedTiles.Count(tile => tile == TreeSquare));
        }