Advertisement
ibragimova_mariam

Stepik robot ex

Feb 8th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public static void moveRobot(RobotConnectionManager robotConnectionManager, int toX, int toY) {
  2. RobotConnection rc = null;
  3. boolean s = false;
  4. for(int i = 0; i < 2; i++)
  5. {
  6. try
  7. {
  8. rc = robotConnectionManager.getConnection();
  9. rc.moveRobotTo(toX, toY);
  10. s = true;
  11. break;
  12. }
  13. catch (RobotConnectionException e)
  14. {
  15. continue;
  16. }
  17. finally
  18. {
  19. if(rc != null)
  20. rc.close();
  21. }
  22. }
  23.  
  24. if(!s) {
  25. try
  26. {
  27. rc = robotConnectionManager.getConnection();
  28. rc.moveRobotTo(toX, toY);
  29. }
  30. finally
  31. {
  32. if(rc != null)
  33. rc.close();
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement