Ejemplo n.º 1
0
        public void PerformAction(RoverLocationDetails roverLocationDetails)
        {
            BoundaryCheckor boundarycheckor = new BoundaryCheckor();

            if (boundarycheckor.CheckBoundary(roverLocationDetails))
            {
                roverLocationDetails.XCurrent += dictionaryX[roverLocationDetails.RoverDirection];
                roverLocationDetails.YCurrent += dictionaryY[roverLocationDetails.RoverDirection];
            }
        }
Ejemplo n.º 2
0
        public bool CheckBoundary(RoverLocationDetails position)
        {
            switch (position.RoverDirection)
            {
            case "north": return(position.YUpper > position.YCurrent);

            case "south": return(position.YLower < position.YCurrent);

            case "east":  return(position.XUpper > position.XCurrent);

            case "west":  return(position.XLower < position.XCurrent);

            case "northeast": return((position.YUpper > position.YCurrent) && (position.XUpper > position.XCurrent));

            case "northwest": return((position.YUpper > position.YCurrent) && (position.XLower < position.XCurrent));

            case "southeast": return((position.YLower < position.YCurrent) && (position.XUpper > position.XCurrent));

            case "southwest": return((position.YLower < position.YCurrent) && (position.XLower < position.XCurrent));

            default: return(false);
            }
        }
 public string GetFinalCoordinate(RoverLocationDetails position)
 {
     return($"{position.XCurrent} {position.YCurrent} {position.RoverDirection}");
 }
Ejemplo n.º 4
0
 public void PerformAction(RoverLocationDetails position)
 {
     position.RoverDirection = ValueDirection[(DirectionValue[position.RoverDirection] + 1) % 8];
 }