@Test(expected = IllegalArgumentException.class) public void testInvalidRomanNumber3() { ConversionRulesEngine.toDecimal("AI"); }
public static long toDecimal(final String romanNumber) { final int len = romanNumber.length(); int difference = 0; long decimalNumber = 0L; char currentChar = '\u0000'; char lookAheadChar = '\u0000'; for (int index = 0; index < len;) { currentChar = Character.toUpperCase(romanNumber.charAt(index)); if (index != (len - 1) && subtractionMap.containsKey(currentChar)) { lookAheadChar = Character.toUpperCase(romanNumber .charAt(index + 1)); if (subtractionMap.get(currentChar).contains(lookAheadChar)) { difference = getDecimalValue(lookAheadChar) - getDecimalValue(currentChar); decimalNumber += difference; index += 2; } else { decimalNumber += getDecimalValue(currentChar); index++; } } else { decimalNumber += getDecimalValue(currentChar); index++; } } return decimalNumber; }
ConversionRulesEngine { public static long toDecimal(final String romanNumber) { final int len = romanNumber.length(); int difference = 0; long decimalNumber = 0L; char currentChar = '\u0000'; char lookAheadChar = '\u0000'; for (int index = 0; index < len;) { currentChar = Character.toUpperCase(romanNumber.charAt(index)); if (index != (len - 1) && subtractionMap.containsKey(currentChar)) { lookAheadChar = Character.toUpperCase(romanNumber .charAt(index + 1)); if (subtractionMap.get(currentChar).contains(lookAheadChar)) { difference = getDecimalValue(lookAheadChar) - getDecimalValue(currentChar); decimalNumber += difference; index += 2; } else { decimalNumber += getDecimalValue(currentChar); index++; } } else { decimalNumber += getDecimalValue(currentChar); index++; } } return decimalNumber; } }
ConversionRulesEngine { public static long toDecimal(final String romanNumber) { final int len = romanNumber.length(); int difference = 0; long decimalNumber = 0L; char currentChar = '\u0000'; char lookAheadChar = '\u0000'; for (int index = 0; index < len;) { currentChar = Character.toUpperCase(romanNumber.charAt(index)); if (index != (len - 1) && subtractionMap.containsKey(currentChar)) { lookAheadChar = Character.toUpperCase(romanNumber .charAt(index + 1)); if (subtractionMap.get(currentChar).contains(lookAheadChar)) { difference = getDecimalValue(lookAheadChar) - getDecimalValue(currentChar); decimalNumber += difference; index += 2; } else { decimalNumber += getDecimalValue(currentChar); index++; } } else { decimalNumber += getDecimalValue(currentChar); index++; } } return decimalNumber; }  }
ConversionRulesEngine { public static long toDecimal(final String romanNumber) { final int len = romanNumber.length(); int difference = 0; long decimalNumber = 0L; char currentChar = '\u0000'; char lookAheadChar = '\u0000'; for (int index = 0; index < len;) { currentChar = Character.toUpperCase(romanNumber.charAt(index)); if (index != (len - 1) && subtractionMap.containsKey(currentChar)) { lookAheadChar = Character.toUpperCase(romanNumber .charAt(index + 1)); if (subtractionMap.get(currentChar).contains(lookAheadChar)) { difference = getDecimalValue(lookAheadChar) - getDecimalValue(currentChar); decimalNumber += difference; index += 2; } else { decimalNumber += getDecimalValue(currentChar); index++; } } else { decimalNumber += getDecimalValue(currentChar); index++; } } return decimalNumber; }  static long toDecimal(final String romanNumber); }
ConversionRulesEngine { public static long toDecimal(final String romanNumber) { final int len = romanNumber.length(); int difference = 0; long decimalNumber = 0L; char currentChar = '\u0000'; char lookAheadChar = '\u0000'; for (int index = 0; index < len;) { currentChar = Character.toUpperCase(romanNumber.charAt(index)); if (index != (len - 1) && subtractionMap.containsKey(currentChar)) { lookAheadChar = Character.toUpperCase(romanNumber .charAt(index + 1)); if (subtractionMap.get(currentChar).contains(lookAheadChar)) { difference = getDecimalValue(lookAheadChar) - getDecimalValue(currentChar); decimalNumber += difference; index += 2; } else { decimalNumber += getDecimalValue(currentChar); index++; } } else { decimalNumber += getDecimalValue(currentChar); index++; } } return decimalNumber; }  static long toDecimal(final String romanNumber); static final Map<Character, List<Character>> subtractionMap; }