RatioNumber extends Number implements Comparable<RatioNumber> { @Override public String toString() { return value + ":" + ratio; } RatioNumber(double value, double ratio); static RatioNumber valueOf(String valueString); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override int compareTo(RatioNumber other); RatioNumber add(RatioNumber other); double value(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final RatioNumber ZERO; }
@Test public void testToString() throws Exception { assertEquals("0.0:0.0", RatioNumber.ZERO.toString()); assertEquals("3.0:4.0", new RatioNumber(3, 4).toString()); }