Commit 3f286ab8 authored by Colin DAMON's avatar Colin DAMON
Browse files

Delete initial zero condition

parent e3612d12
......@@ -2,18 +2,15 @@ package fr.ippon.kata.numeral;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Optional;
import java.util.TreeMap;
public class Numerals {
private static final NavigableMap<Integer, String> CONVERSIONS = buildConversions();
public static String toRoman(int arabic) {
if (arabic == 0) {
return "";
}
Entry<Integer, String> highestKnownConversion = CONVERSIONS.floorEntry(arabic);
return highestKnownConversion.getValue() + toRoman(arabic - highestKnownConversion.getKey());
Optional<Entry<Integer, String>> highestKnownConversion = Optional.ofNullable(CONVERSIONS.floorEntry(arabic));
return highestKnownConversion.map(conversion -> conversion.getValue() + toRoman(arabic - conversion.getKey())).orElse("");
}
private static NavigableMap<Integer, String> buildConversions() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment