コード例 #1
0
ファイル: Forward.cs プロジェクト: tavisca-rsingh/MarsRover
        public void PerformAction(RoverLocationDetails roverLocationDetails)
        {
            BoundaryCheckor boundarycheckor = new BoundaryCheckor();

            if (boundarycheckor.CheckBoundary(roverLocationDetails))
            {
                roverLocationDetails.XCurrent += dictionaryX[roverLocationDetails.RoverDirection];
                roverLocationDetails.YCurrent += dictionaryY[roverLocationDetails.RoverDirection];
            }
        }
コード例 #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);
            }
        }
コード例 #3
0
 public string GetFinalCoordinate(RoverLocationDetails position)
 {
     return($"{position.XCurrent} {position.YCurrent} {position.RoverDirection}");
 }
コード例 #4
0
ファイル: Right.cs プロジェクト: tavisca-rsingh/MarsRover
 public void PerformAction(RoverLocationDetails position)
 {
     position.RoverDirection = ValueDirection[(DirectionValue[position.RoverDirection] + 1) % 8];
 }