@Test public void GIVEN_non_null_wind_direction_WHEN_cardinal_direction_formatting_requested_THEN_returns_cardinal_direction_value() { testee = new WindDirectionFormatter(new WindDirection(0)); assertEquals("N", testee.format(WindDirectionUnit.CARDINAL_DIRECTION)); testee = new WindDirectionFormatter(new WindDirection(338)); assertEquals("NNW", testee.format(WindDirectionUnit.CARDINAL_DIRECTION)); }
public String format(WindDirectionUnit unit) { String formatted; if (windDirection != null) { if (unit == COMPASS_DEGREES) { formatted = String.format(Locale.US, "%1d°", windDirection.getCompassDegrees()); } else { formatted = String.format(Locale.US, "%1s", windDirection.getCardinalDirection().name()); } } else { if (unit == WindDirectionUnit.COMPASS_DEGREES) { formatted = "---°"; } else { formatted = "---"; } } return formatted; }
WindDirectionFormatter { public String format(WindDirectionUnit unit) { String formatted; if (windDirection != null) { if (unit == COMPASS_DEGREES) { formatted = String.format(Locale.US, "%1d°", windDirection.getCompassDegrees()); } else { formatted = String.format(Locale.US, "%1s", windDirection.getCardinalDirection().name()); } } else { if (unit == WindDirectionUnit.COMPASS_DEGREES) { formatted = "---°"; } else { formatted = "---"; } } return formatted; } }
WindDirectionFormatter { public String format(WindDirectionUnit unit) { String formatted; if (windDirection != null) { if (unit == COMPASS_DEGREES) { formatted = String.format(Locale.US, "%1d°", windDirection.getCompassDegrees()); } else { formatted = String.format(Locale.US, "%1s", windDirection.getCardinalDirection().name()); } } else { if (unit == WindDirectionUnit.COMPASS_DEGREES) { formatted = "---°"; } else { formatted = "---"; } } return formatted; } WindDirectionFormatter(WindDirection windDirection); }
WindDirectionFormatter { public String format(WindDirectionUnit unit) { String formatted; if (windDirection != null) { if (unit == COMPASS_DEGREES) { formatted = String.format(Locale.US, "%1d°", windDirection.getCompassDegrees()); } else { formatted = String.format(Locale.US, "%1s", windDirection.getCardinalDirection().name()); } } else { if (unit == WindDirectionUnit.COMPASS_DEGREES) { formatted = "---°"; } else { formatted = "---"; } } return formatted; } WindDirectionFormatter(WindDirection windDirection); String format(WindDirectionUnit unit); }
WindDirectionFormatter { public String format(WindDirectionUnit unit) { String formatted; if (windDirection != null) { if (unit == COMPASS_DEGREES) { formatted = String.format(Locale.US, "%1d°", windDirection.getCompassDegrees()); } else { formatted = String.format(Locale.US, "%1s", windDirection.getCardinalDirection().name()); } } else { if (unit == WindDirectionUnit.COMPASS_DEGREES) { formatted = "---°"; } else { formatted = "---"; } } return formatted; } WindDirectionFormatter(WindDirection windDirection); String format(WindDirectionUnit unit);  }