@Test public void testResolveRobotCount() throws Exception { List<RobotInfo> testString = new ArrayList<>(); for (String name: new String[] {"Robot2", "Robot3", "Robot-2", "Robot3d", "R0b0t11", "Robot7"}) { testString.add(new RobotInfo(null, name, null, null, null, null, null, null, null)); } RobotInfo.resolveRobotCount(testString); assertEquals(RobotInfo.getRobotCount(), 8); }
public static void resolveRobotCount(List<RobotInfo> list) { int max = 0; int val; for (RobotInfo info: list) { if (info.getName().startsWith("Robot")) { try { val = Integer.parseInt(info.getName().substring(5)); } catch (NumberFormatException e) { val = -1; } if (val > max) max = val; } } robotCount = max + 1; }
RobotInfo implements Comparable<RobotInfo>, Savable { public static void resolveRobotCount(List<RobotInfo> list) { int max = 0; int val; for (RobotInfo info: list) { if (info.getName().startsWith("Robot")) { try { val = Integer.parseInt(info.getName().substring(5)); } catch (NumberFormatException e) { val = -1; } if (val > max) max = val; } } robotCount = max + 1; } }
RobotInfo implements Comparable<RobotInfo>, Savable { public static void resolveRobotCount(List<RobotInfo> list) { int max = 0; int val; for (RobotInfo info: list) { if (info.getName().startsWith("Robot")) { try { val = Integer.parseInt(info.getName().substring(5)); } catch (NumberFormatException e) { val = -1; } if (val > max) max = val; } } robotCount = max + 1; } RobotInfo();  RobotInfo(UUID id, String name, String masterUriString, String joystickTopic,
                     String laserTopic, String cameraTopic,String navsatTopic,
                     String odometryTopic, String poseTopic, boolean reverseLaserScan,
                     boolean invertX, boolean invertY, boolean invertAngularVelocity); }
RobotInfo implements Comparable<RobotInfo>, Savable { public static void resolveRobotCount(List<RobotInfo> list) { int max = 0; int val; for (RobotInfo info: list) { if (info.getName().startsWith("Robot")) { try { val = Integer.parseInt(info.getName().substring(5)); } catch (NumberFormatException e) { val = -1; } if (val > max) max = val; } } robotCount = max + 1; } RobotInfo();  RobotInfo(UUID id, String name, String masterUriString, String joystickTopic,
                     String laserTopic, String cameraTopic,String navsatTopic,
                     String odometryTopic, String poseTopic, boolean reverseLaserScan,
                     boolean invertX, boolean invertY, boolean invertAngularVelocity); UUID getId(); void setId(UUID id); String getPoseTopic(); void setPoseTopic(String poseTopic); String getOdometryTopic(); void setOdometryTopic(String odometryTopic); String getNavSatTopic(); void setNavSatTopic(String navsatTopic); String getJoystickTopic(); void setJoystickTopic(String joystickTopic); String getCameraTopic(); void setCameraTopic(String cameraTopic); String getLaserTopic(); void setLaserTopic(String laserTopic); String getMasterUri(); void setMasterUri(String mMasterUri); String getName(); void setName(String mName); URI getUri(); boolean isReverseLaserScan(); void setReverseLaserScan(boolean reverseLaserScan); boolean isInvertX(); void setInvertX(boolean invertX); boolean isInvertY(); void setInvertY(boolean invertY); boolean isInvertAngularVelocity(); void setInvertAngularVelocity(boolean invertAngularVelocity); @Override int compareTo(@NonNull RobotInfo another); static void resolveRobotCount(List<RobotInfo> list); @Override void load(@NonNull Bundle bundle); void load(@NonNull SharedPreferences prefs); @Override void save(@NonNull Bundle bundle); void save(@NonNull SharedPreferences.Editor prefs); }
RobotInfo implements Comparable<RobotInfo>, Savable { public static void resolveRobotCount(List<RobotInfo> list) { int max = 0; int val; for (RobotInfo info: list) { if (info.getName().startsWith("Robot")) { try { val = Integer.parseInt(info.getName().substring(5)); } catch (NumberFormatException e) { val = -1; } if (val > max) max = val; } } robotCount = max + 1; } RobotInfo();  RobotInfo(UUID id, String name, String masterUriString, String joystickTopic,
                     String laserTopic, String cameraTopic,String navsatTopic,
                     String odometryTopic, String poseTopic, boolean reverseLaserScan,
                     boolean invertX, boolean invertY, boolean invertAngularVelocity); UUID getId(); void setId(UUID id); String getPoseTopic(); void setPoseTopic(String poseTopic); String getOdometryTopic(); void setOdometryTopic(String odometryTopic); String getNavSatTopic(); void setNavSatTopic(String navsatTopic); String getJoystickTopic(); void setJoystickTopic(String joystickTopic); String getCameraTopic(); void setCameraTopic(String cameraTopic); String getLaserTopic(); void setLaserTopic(String laserTopic); String getMasterUri(); void setMasterUri(String mMasterUri); String getName(); void setName(String mName); URI getUri(); boolean isReverseLaserScan(); void setReverseLaserScan(boolean reverseLaserScan); boolean isInvertX(); void setInvertX(boolean invertX); boolean isInvertY(); void setInvertY(boolean invertY); boolean isInvertAngularVelocity(); void setInvertAngularVelocity(boolean invertAngularVelocity); @Override int compareTo(@NonNull RobotInfo another); static void resolveRobotCount(List<RobotInfo> list); @Override void load(@NonNull Bundle bundle); void load(@NonNull SharedPreferences prefs); @Override void save(@NonNull Bundle bundle); void save(@NonNull SharedPreferences.Editor prefs); static final String UUID_KEY; static final String ROBOT_NAME_KEY; static final String MASTER_URI_KEY; static final String JOYSTICK_TOPIC_KEY; static final String LASER_SCAN_TOPIC_KEY; static final String CAMERA_TOPIC_KEY; static final String NAVSAT_TOPIC_KEY; static final String ODOMETRY_TOPIC_KEY; static final String POSE_TOPIC_KEY; static final String REVERSE_LASER_SCAN_KEY; static final String INVERT_X_KEY; static final String INVERT_Y_KEY; static final String INVERT_ANGULAR_VELOCITY_KEY; }