Duplication: there is two loops appending letters, we want to remove one because
both of them are doing the same.
public static String romanFor(int decimal) {
String roman = "";
for (RomanToDecimal romanToDecimal : RomanToDecimal.values()) {
- if (decimal >= romanToDecimal.decimal) {
+ while (decimal >= romanToDecimal.decimal) {
roman += romanToDecimal.roman;
decimal -= romanToDecimal.decimal;
}
assertThat(romanFor(7), is("VII"));
assertThat(romanFor(10), is("X"));
assertThat(romanFor(18), is("XVIII"));
+ assertThat(romanFor(30), is("XXX"));
}
}