Change some int displays to Roman Numerals

May not be 100% accurate if you somehow manage to get these really, really high, but it's good enough.
This commit is contained in:
Nick 2016-04-17 13:51:39 -07:00
parent d71f181729
commit a4f55d88b6
7 changed files with 45 additions and 7 deletions

View file

@ -0,0 +1,32 @@
package WayofTime.bloodmagic.util.helper;
import java.util.TreeMap;
public class NumeralHelper {
private static final TreeMap<Integer, String> romanNumerals = new TreeMap<Integer, String>();
static {
romanNumerals.put(1000, "M" );
romanNumerals.put(900 , "CM");
romanNumerals.put(500 , "D" );
romanNumerals.put(400 , "CD");
romanNumerals.put(100 , "C" );
romanNumerals.put(90 , "XC");
romanNumerals.put(50 , "L" );
romanNumerals.put(40 , "XL");
romanNumerals.put(10 , "X" );
romanNumerals.put(9 , "IX");
romanNumerals.put(5 , "V" );
romanNumerals.put(4 , "IV");
romanNumerals.put(1 , "I" );
}
public static String toRoman(int arabic) {
int convert = romanNumerals.floorKey(arabic);
if (arabic == convert)
return romanNumerals.get(convert);
return romanNumerals.get(convert) + toRoman(arabic - convert);
}
}