@Test public void testDistance() throws Exception { double out; out = Dimensions.convert(1.0, Dimensions.Dim.CM, Dimensions.Dim.DEC); assertTrue(Math.abs(out - 0.1) < 0.0001); out = Dimensions.convert(1.0, Dimensions.Dim.FOOT, Dimensions.Dim.CM); assertTrue(Math.abs(out - 30.48) < 0.0001); out = Dimensions.convert(1.0, Dimensions.Dim.INCH, Dimensions.Dim.CM); assertTrue(Math.abs(out - 2.54) < 0.0001); out = Dimensions.convert(1.0, Dimensions.Dim.INCH, Dimensions.Dim.FOOT); assertTrue(Math.abs(out - 0.08333333333333333) < 0.0001); }
public static double convert(double value, Dim fromDimention, Dim toDimention) { if (fromDimention.type != toDimention.type) { throw new IllegalArgumentException("To dimension and from dimension must be equal while converting."); } return conversionRatios.get(fromDimention) / conversionRatios.get(toDimention) * value; }
Dimensions { public static double convert(double value, Dim fromDimention, Dim toDimention) { if (fromDimention.type != toDimention.type) { throw new IllegalArgumentException("To dimension and from dimension must be equal while converting."); } return conversionRatios.get(fromDimention) / conversionRatios.get(toDimention) * value; } }
Dimensions { public static double convert(double value, Dim fromDimention, Dim toDimention) { if (fromDimention.type != toDimention.type) { throw new IllegalArgumentException("To dimension and from dimension must be equal while converting."); } return conversionRatios.get(fromDimention) / conversionRatios.get(toDimention) * value; }  }
Dimensions { public static double convert(double value, Dim fromDimention, Dim toDimention) { if (fromDimention.type != toDimention.type) { throw new IllegalArgumentException("To dimension and from dimension must be equal while converting."); } return conversionRatios.get(fromDimention) / conversionRatios.get(toDimention) * value; }  static ObservableList<Item> getList(final Type dimType); static int getIndex(final Type dimType, Dim dimension); static double convert(double value, Dim fromDimention, Dim toDimention); }
Dimensions { public static double convert(double value, Dim fromDimention, Dim toDimention) { if (fromDimention.type != toDimention.type) { throw new IllegalArgumentException("To dimension and from dimension must be equal while converting."); } return conversionRatios.get(fromDimention) / conversionRatios.get(toDimention) * value; }  static ObservableList<Item> getList(final Type dimType); static int getIndex(final Type dimType, Dim dimension); static double convert(double value, Dim fromDimention, Dim toDimention);  }