Commit 435dc53b authored by Colin DAMON's avatar Colin DAMON
Browse files

Create conversion map

parent 72b71807
package fr.ippon.kata.numeral; package fr.ippon.kata.numeral;
import java.util.NavigableMap;
import java.util.TreeMap;
public class Numerals { public class Numerals {
private static final NavigableMap<Integer, String> CONVERSIONS = buildConversions();
public static String toRoman(int arabic) { public static String toRoman(int arabic) {
if (arabic >= 5) { if (arabic >= 5) {
...@@ -13,4 +17,14 @@ public class Numerals { ...@@ -13,4 +17,14 @@ public class Numerals {
return "I".repeat(arabic); return "I".repeat(arabic);
} }
private static NavigableMap<Integer, String> buildConversions() {
NavigableMap<Integer, String> conversions = new TreeMap<>();
conversions.put(1, "I");
conversions.put(4, "IV");
conversions.put(5, "V");
return conversions;
}
} }
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