Пример #1
0
        public void Execute(Robot robot, string parameters)
        {
            var inputs = parameters.Split(",");

            if (inputs.Length != 3)
            {
                throw new ArgumentException("Expected X,Y,F");
            }

            int x, y;

            if (!Int32.TryParse(inputs[0], out x))
            {
                throw new ArgumentException("Invalid X parameter for PLACE");
            }
            if (!Int32.TryParse(inputs[1], out y))
            {
                throw new ArgumentException("Invalid Y parameter for PLACE");
            }
            if (!Bearing.IsValidBearing(inputs[2]))
            {
                throw new ArgumentException("Invalid F parameter for PLACE");
            }

            robot.SetPosition(x, y);
            robot.SetBearing(inputs[2]);
        }
Пример #2
0
 public bool CanExecute(Robot robot)
 {
     // Need a valid current position and bearing to move
     return(robot.xPos != null && robot.yPos != null && Bearing.IsValidBearing(robot.bearing));
 }
Пример #3
0
 public void TestIsValidBearingTrue()
 {
     Assert.IsTrue(Bearing.IsValidBearing("NORTH"));
 }
Пример #4
0
 public void TestIsValidBearingFalse()
 {
     Assert.IsFalse(Bearing.IsValidBearing("SPAM"));
 }
Пример #5
0
 public bool CanExecute(Robot robot)
 {
     // Need a valid current bearing to turn
     return(Bearing.IsValidBearing(robot.bearing));
 }