LaserMeasurement { @NonNull public static CharSequence render(@NonNull List<LaserMeasurement> points, boolean metric) { final double units = metric ? 1 : 3.28084; final StringBuilder sb = new StringBuilder(); for (LaserMeasurement point : points) { sb.append(String.format(Locale.US, "%.1f, %.1f\n", point.x * units, point.y * units)); } return sb; } LaserMeasurement(double x, double y); @NonNull @Override String toString(); @NonNull static List<LaserMeasurement> parse(@NonNull String pointString, boolean metric, boolean strict); @NonNull static List<LaserMeasurement> parseSafe(@NonNull String pointString, boolean metric); @NonNull static CharSequence render(@NonNull List<LaserMeasurement> points, boolean metric); @NonNull static List<LaserMeasurement> reorder(@NonNull List<LaserMeasurement> points); final double x; final double y; }
@Test public void render() { final List<LaserMeasurement> points = testPoints(); assertEquals("100.0, -100.0\n", LaserMeasurement.render(points, true).toString()); assertEquals("328.1, -328.1\n", LaserMeasurement.render(points, false).toString()); }