コード例 #1
0
ファイル: RobotOperator.cs プロジェクト: m0rris0n/RobotWars
 /// <summary>
 /// Cycles through the instruction string and acts according to the character discovered.
 /// Where "M" is found operator attempts the move function, and if it fails, increases the
 /// robot's penalities by 1.
 /// Where an "L" or "R" are read , the rotate method is fired with the rotatation
 /// direction as the parameter.
 /// </summary>
 /// <param name="instructions">the M/L/R combo string for the robot's movement</param>
 public string ExecuteInstructions(string instructions)
 {
     foreach (char c in instructions)
     {
         if (c.ToString() == "M")
         {
             if (Move() == false)
             {
                 _robot.Penalties++;
             }
         }
         else
         {
             Rotate(c.ToString());
         }
     }
     return(_robot.ReportLocation());
 }