### Question:
Size { public float getAspectRatio() { if (width == 0 || height == 0) { return Float.NaN; } return (float) width / height; } Size(int width, int height); float getAspectRatio(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @SuppressWarnings("SuspiciousNameCombination") Size flip(); final int width; final int height; }### Answer:
@Test public void getAspectRatio() throws Exception { assertEquals( 2.5f, new Size(250, 100).getAspectRatio(), 1e-6 ); }
@Test public void getAspectRatio_EmptySize() throws Exception { assertEquals( Float.NaN, new Size(0, 0).getAspectRatio(), 1e-6 ); }