예제 #1
0
 private void ThenIExpectAPlateau(Plateau plateau, int expectedUpperX, int expectedUpperY)
 {
     Assert.IsNotNull(plateau);
     Assert.AreEqual(plateau.UpperRightX, expectedUpperX);
     Assert.AreEqual(plateau.UpperRightY, expectedUpperY);
     Assert.AreEqual(plateau.LowerLeftX, 0);
     Assert.AreEqual(plateau.LowerLeftY, 0);
 }
예제 #2
0
 public string SetCommands(string command, Plateau plateau)
 {
     foreach (char letter in command)
     {
         switch (letter)
         {
             case 'L':
                 TurnLeft();
                 break;
             case 'R':
                 TurnRight();
                 break;
             case 'M':
                 Move(plateau);
                 break;
             default:
                 throw new Exception("Invalid command!");
         }
     }
     return getPosition();
 }
예제 #3
0
 public bool isRoverInsidePlateau(Plateau plateau)
 {
     switch (CardinalCompass)
     {
         case CardinalCompass.North:
             if (PointY != plateau.UpperRightY)
                 return true;
             else return false;
         case CardinalCompass.South:
             if (PointY != plateau.LowerLeftY)
                 return true;
             else return false;
         case CardinalCompass.East:
             if (PointX != plateau.UpperRightX)
                 return true;
             else return false;
         case CardinalCompass.West:
             if (PointX != plateau.LowerLeftX)
                 return true;
             else return false;
     }
     return false;
 }
예제 #4
0
 private void Move(Plateau plateau)
 {
     if (!isRoverInsidePlateau(plateau))
     {
         throw new Exception("Rover cannot go outside the plateau!");
     }
     switch (CardinalCompass)
     {
         case CardinalCompass.North:
             PointY++;
             break;
         case CardinalCompass.South:
             PointY--;
             break;
         case CardinalCompass.East:
             PointX++;
             break;
         case CardinalCompass.West:
             PointX--;
             break;
     }
 }