@Status(stage=PRODUCTION, unitTests=COMPLETE) @Review(by="Kees Schotanus", at="2009-09-28") @ThreadSafety(level=IMMUTABLE, doc="Utility class with static methods only") public final class RomanNumbers extends Object
Modifier and Type | Field and Description |
---|---|
static int |
C
Arabic value of the Roman number C.
|
static int |
D
Arabic value of the Roman number D.
|
static int |
I
Arabic value of the Roman number I.
|
static int |
L
Arabic value of the Roman number L.
|
static int |
LARGEST_ROMAN_NUMBER
The largest number the Romans could represent.
|
static int |
M
Arabic value of the Roman number M.
|
static int |
V
Arabic value of the Roman number V.
|
static int |
X
Arabic value of the Roman number X.
|
Modifier and Type | Method and Description |
---|---|
static int |
getValue(char romanNumeral)
Gets the value of one Roman numeral.
|
static boolean |
isValid(String romanNumber)
Determines whether a Roman number is a valid Roman number or not.
|
static void |
main(String[] args)
Tests the above functionality.
|
static int |
toArabic(String number)
Converts a Roman number to an Arabic number.
|
static String |
toRoman(int number)
Converts an Arabic number to a Roman number.
|
public static final int LARGEST_ROMAN_NUMBER
public static final int I
public static final int V
public static final int X
public static final int L
public static final int C
public static final int D
public static final int M
public static String toRoman(int number)
number
- Arabic number to convert.IllegalArgumentException
- When the Arabic number is not in the
range: 0 <= number <= LARGEST_ROMAN_NUMBER
.public static int toArabic(String number)
number
- Roman number to convert.IllegalArgumentException
- When the Roman number contains numerals
that are not legal Roman numerals.NullPointerException
- When the supplied number is null.public static boolean isValid(String romanNumber)
romanNumber
- Valid or invalid Roman number.NullPointerException
- When the supplied romanNumber is null.public static int getValue(char romanNumeral)
romanNumeral
- Roman numeral.IllegalArgumentException
- When the supplied Roman numeral is not
a valid Roman numeral.public static void main(String[] args)
args
- Exactly one argument should be supplied. It should either
be an Arabic number or a Roman number. The supplied parameter is
converted and the result will be displayed.Copyright © 2008–2018. All rights reserved.