Package wbs.utils.util.string
Class RomanNumerals
java.lang.Object
wbs.utils.util.string.RomanNumerals
-
Method Summary
Modifier and TypeMethodDescriptionstatic intfromRomanNumerals(String numerals) Convert a given Roman numeral string to an intstatic doublefromRomanNumeralsDecimal(String numerals) Convert a given Roman numeral string to a doublestatic intnumeralOf(char numeral) Get the number associated with a given numeral.static StringtoRoman(double number) Converts a double to roman numerals with a decimal point, despite that not being "true" roman numerals.static StringtoRoman(int number) Convert an integer to roman numerals
-
Method Details
-
toRoman
Convert an integer to roman numerals- Parameters:
number- The number to convert- Returns:
- The roman numeral of the given number.
If the given number is 0, then "0" is returned.
If the given number is negative, then the roman numeral of the absolute value is returned, prepended with "-".
-
toRoman
Converts a double to roman numerals with a decimal point, despite that not being "true" roman numerals. If the double has no decimal component, this method functions the same astoRoman(int).- Parameters:
number- The double to convert- Returns:
- The roman numeral version
-
numeralOf
Get the number associated with a given numeral.- Parameters:
numeral- The numeral to convert to an integer.- Returns:
- The integer version, 0 if the numeral was '0'.
- Throws:
IllegalArgumentException- If the char is not a valid roman numeral
-
fromRomanNumerals
Convert a given Roman numeral string to an int- Parameters:
numerals- The Roman numeral string to convert- Returns:
- The value of the given roman numeral
- Throws:
IllegalArgumentException- If the string contained any invalid characters, or if the given string contained a decimal place.
-
fromRomanNumeralsDecimal
Convert a given Roman numeral string to a double- Parameters:
numerals- The Roman numeral string to convert- Returns:
- The value of the given roman numeral
- Throws:
IllegalArgumentException- If the string contained any invalid characters, or if there more than 1 "." to denote a decimal point.
-