// (TL, TL, A) public bool execStrategy(OpMap m, IMotionControl mc) { try { m.turnLeft(); mc.turnLeft(); m.turnLeft(); mc.turnLeft(); m.advance(); mc.advance(); } catch (CannotComplyException) { return(false); } catch (NotEnoughBatteryException) { return(false); } catch (OutOfBatteryException) { return(false); } catch (Exception) { return(false); } return(true); }
public void execProgram(Command[] cmds) { for (int i = 0; i < cmds.Length; i += 1) { try { switch (cmds[i]) { case Command.TL: map.turnLeft(); motCtrl.turnLeft(); break; case Command.TR: map.turnRight(); motCtrl.turnRight(); break; case Command.A: map.advance(); motCtrl.advance(); break; case Command.B: map.back(); motCtrl.back(); break; case Command.C: map.clean(); motCtrl.clean(); break; } } catch (CannotComplyException) { execBackoff(); if (error) { // All backoff strategies had failed. Execution finished return; } i -= 1; } catch (NotEnoughBatteryException) { return; } catch (OutOfBatteryException) { return; } catch (Exception) { error = true; } } }
public void advance_batteryDecrease2_return3() { proc.advance(); Assert.AreEqual(3, proc.Battery); }