public void ProcessCommand(Command command) { switch (command) { case Command.MoveForward: _rover.MoveForward(); _logger.Log("Rover moved forward."); _logger.Log(FormatRover()); break; case Command.MoveBackward: _rover.MoveBackward(); _logger.Log("Rover moved backward."); _logger.Log(FormatRover()); break; case Command.TurnLeft: _rover.TurnLeft(); _logger.Log("Rover turned left."); _logger.Log(FormatRover()); break; case Command.TurnRight: _rover.TurnRight(); _logger.Log("Rover turned right."); _logger.Log(FormatRover()); break; case Command.Quit: _logger.Log("Rover stopped."); _logger.Log(FormatRover()); break; } }
public void ProcessCommands(String commands) { foreach (var command in commands) { if (command == Forward) { rover.MoveForward(); } else if (command == Backward) { rover.MoveBackward(); } else if (command == Left) { rover.TurnLeft(); } else if (command == Right) { rover.TurnRight(); } if (rover.IsObstructed) { break; } } }
private void HandleCharacter(char ch) { switch (ch) { case 'F': rover.MoveForward(); break;; case 'B': rover.MoveBackward(); break; case 'R': rover.TurnRight(); break; case 'L': rover.TurnLeft(); break; default: throw new InvalidEnumArgumentException(string.Format("The received command : '%0' is not supported", ch)); } }
public ICmdResult Execute() { return(rover.MoveBackward()); }