Class RomanNumerals

java.lang.Object
wbs.utils.util.string.RomanNumerals

public final class RomanNumerals extends Object
  • Method Details

    • toRoman

      public static String toRoman(int number)
      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

      public static String toRoman(double number)
      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 as toRoman(int).
      Parameters:
      number - The double to convert
      Returns:
      The roman numeral version
    • numeralOf

      public static int numeralOf(char numeral) throws IllegalArgumentException
      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

      public static int fromRomanNumerals(String numerals) throws IllegalArgumentException
      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

      public static double fromRomanNumeralsDecimal(String numerals)
      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.