Example #1
0
 private string GenerateObstructionReport(Coordinates blockingObstacleCoords, char moveInstruction)
 {
     return string.Format("Cannot move {0}. Obstacle encountered at {1},{2}.",
         CalculateDirectionOfMove(moveInstruction, Heading).ToHeadingDescription(), blockingObstacleCoords.X,
         blockingObstacleCoords.Y);
 }
Example #2
0
 public Rover(int xStartCoord, int yStartCoord, params Obstacle[] obstacles)
 {
     Coordinates = new Coordinates(xStartCoord, yStartCoord);
     Heading = 'N';
     Obstacles = obstacles;
 }
Example #3
0
 private Coordinates CalculateNewPosition(char instruction)
 {
     int x = X;
     int y = Y;
     bool isForwards = instruction == 'F';
     switch (Heading)
     {
         case 'N':
             y = Y + (isForwards ? 1 : -1);
             break;
         case 'S':
             y = Y + (isForwards ? -1 : 1);
             break;
         case 'E':
             x = X + (isForwards ? 1 : -1);
             break;
         case 'W':
             x = X + (isForwards ? -1 : 1);
             break;
     }
     var newCoords = new Coordinates(x, y);
     return newCoords.Wrap();
 }