@Test public void testVersionVals() { Assert.assertTrue(VersionVal.interpretVersionValue("4.3.2") == 432); Assert.assertTrue(VersionVal.interpretVersionValue("4.1.3") == 413); Assert.assertTrue(VersionVal.interpretVersionValue("5.1.0") == 510); try { VersionVal.interpretVersionValue("4.1."); Assert.fail(); } catch (IllegalArgumentException e) { } try { VersionVal.interpretVersionValue("4.1"); Assert.fail(); } catch (IllegalArgumentException e) { } try { VersionVal.interpretVersionValue("4."); Assert.fail(); } catch (IllegalArgumentException e) { } try { VersionVal.interpretVersionValue("5.3.2.3"); Assert.fail(); } catch (IllegalArgumentException e) { } }
public static int interpretVersionValue(String ver) { StringTokenizer tokenizer = new StringTokenizer(ver,"."); if (tokenizer.countTokens() == 3) { int first = Integer.parseInt(tokenizer.nextToken()) * 100; int second = Integer.parseInt(tokenizer.nextToken())*10; int third = Integer.parseInt(tokenizer.nextToken()); return first + second + third; } else throw new IllegalArgumentException("illegal version value '"+ver+"'"); }
VersionVal { public static int interpretVersionValue(String ver) { StringTokenizer tokenizer = new StringTokenizer(ver,"."); if (tokenizer.countTokens() == 3) { int first = Integer.parseInt(tokenizer.nextToken()) * 100; int second = Integer.parseInt(tokenizer.nextToken())*10; int third = Integer.parseInt(tokenizer.nextToken()); return first + second + third; } else throw new IllegalArgumentException("illegal version value '"+ver+"'"); } }
VersionVal { public static int interpretVersionValue(String ver) { StringTokenizer tokenizer = new StringTokenizer(ver,"."); if (tokenizer.countTokens() == 3) { int first = Integer.parseInt(tokenizer.nextToken()) * 100; int second = Integer.parseInt(tokenizer.nextToken())*10; int third = Integer.parseInt(tokenizer.nextToken()); return first + second + third; } else throw new IllegalArgumentException("illegal version value '"+ver+"'"); }  }
VersionVal { public static int interpretVersionValue(String ver) { StringTokenizer tokenizer = new StringTokenizer(ver,"."); if (tokenizer.countTokens() == 3) { int first = Integer.parseInt(tokenizer.nextToken()) * 100; int second = Integer.parseInt(tokenizer.nextToken())*10; int third = Integer.parseInt(tokenizer.nextToken()); return first + second + third; } else throw new IllegalArgumentException("illegal version value '"+ver+"'"); }  static int interpretVersionValue(String ver); }
VersionVal { public static int interpretVersionValue(String ver) { StringTokenizer tokenizer = new StringTokenizer(ver,"."); if (tokenizer.countTokens() == 3) { int first = Integer.parseInt(tokenizer.nextToken()) * 100; int second = Integer.parseInt(tokenizer.nextToken())*10; int third = Integer.parseInt(tokenizer.nextToken()); return first + second + third; } else throw new IllegalArgumentException("illegal version value '"+ver+"'"); }  static int interpretVersionValue(String ver);  }