@Test public void GIVEN_null_uv_index_WHEN_color_requested_THEN_white_color_returned() { testee = new UvIndexColorizer(null); assertEquals(UvIndexColorizer.WHITE, testee.colorize()); }
public int colorize() { int colorCode = WHITE; if (uvIndex != null) { int uvIndexRounded = uvIndex.setScale(0, RoundingMode.HALF_DOWN).intValue(); if (uvIndexRounded < 3) { colorCode = GREEN; } else if (uvIndexRounded > 10) { colorCode = PURPLE; } else { switch (uvIndexRounded) { case 3: case 4: case 5: colorCode = YELLOW; break; case 6: case 7: colorCode = ORANGE; break; case 8: case 9: case 10: colorCode = RED; break; } } } return colorCode; }
UvIndexColorizer { public int colorize() { int colorCode = WHITE; if (uvIndex != null) { int uvIndexRounded = uvIndex.setScale(0, RoundingMode.HALF_DOWN).intValue(); if (uvIndexRounded < 3) { colorCode = GREEN; } else if (uvIndexRounded > 10) { colorCode = PURPLE; } else { switch (uvIndexRounded) { case 3: case 4: case 5: colorCode = YELLOW; break; case 6: case 7: colorCode = ORANGE; break; case 8: case 9: case 10: colorCode = RED; break; } } } return colorCode; } }
UvIndexColorizer { public int colorize() { int colorCode = WHITE; if (uvIndex != null) { int uvIndexRounded = uvIndex.setScale(0, RoundingMode.HALF_DOWN).intValue(); if (uvIndexRounded < 3) { colorCode = GREEN; } else if (uvIndexRounded > 10) { colorCode = PURPLE; } else { switch (uvIndexRounded) { case 3: case 4: case 5: colorCode = YELLOW; break; case 6: case 7: colorCode = ORANGE; break; case 8: case 9: case 10: colorCode = RED; break; } } } return colorCode; } UvIndexColorizer(BigDecimal uvIndex); }
UvIndexColorizer { public int colorize() { int colorCode = WHITE; if (uvIndex != null) { int uvIndexRounded = uvIndex.setScale(0, RoundingMode.HALF_DOWN).intValue(); if (uvIndexRounded < 3) { colorCode = GREEN; } else if (uvIndexRounded > 10) { colorCode = PURPLE; } else { switch (uvIndexRounded) { case 3: case 4: case 5: colorCode = YELLOW; break; case 6: case 7: colorCode = ORANGE; break; case 8: case 9: case 10: colorCode = RED; break; } } } return colorCode; } UvIndexColorizer(BigDecimal uvIndex); int colorize(); }
UvIndexColorizer { public int colorize() { int colorCode = WHITE; if (uvIndex != null) { int uvIndexRounded = uvIndex.setScale(0, RoundingMode.HALF_DOWN).intValue(); if (uvIndexRounded < 3) { colorCode = GREEN; } else if (uvIndexRounded > 10) { colorCode = PURPLE; } else { switch (uvIndexRounded) { case 3: case 4: case 5: colorCode = YELLOW; break; case 6: case 7: colorCode = ORANGE; break; case 8: case 9: case 10: colorCode = RED; break; } } } return colorCode; } UvIndexColorizer(BigDecimal uvIndex); int colorize(); static final int WHITE; static final int GREEN; static final int YELLOW; static final int ORANGE; static final int RED; static final int PURPLE; }