@Test void convertV() { assertEquals(5, convertRomanToArabicNumber("V"), "Roman V should equal to 5"); }
static int convertRomanToArabicNumber(String roman) { roman = roman.toUpperCase(); int sum = 0; int current = 0; int previous = 0; for (int index = roman.length() - 1; index >= 0; index--) { if (doesSymbolsContainsRomanCharacter(roman, index)) { current = getSymbolValue(roman, index); if (current < previous) { sum -= current; } else { sum += current; } previous = current; } else { throw new IllegalArgumentException( String.format("Invalid roman character %s ", getCharValue(roman, index))); } } return sum; }
RomanConverter { static int convertRomanToArabicNumber(String roman) { roman = roman.toUpperCase(); int sum = 0; int current = 0; int previous = 0; for (int index = roman.length() - 1; index >= 0; index--) { if (doesSymbolsContainsRomanCharacter(roman, index)) { current = getSymbolValue(roman, index); if (current < previous) { sum -= current; } else { sum += current; } previous = current; } else { throw new IllegalArgumentException( String.format("Invalid roman character %s ", getCharValue(roman, index))); } } return sum; } }
RomanConverter { static int convertRomanToArabicNumber(String roman) { roman = roman.toUpperCase(); int sum = 0; int current = 0; int previous = 0; for (int index = roman.length() - 1; index >= 0; index--) { if (doesSymbolsContainsRomanCharacter(roman, index)) { current = getSymbolValue(roman, index); if (current < previous) { sum -= current; } else { sum += current; } previous = current; } else { throw new IllegalArgumentException( String.format("Invalid roman character %s ", getCharValue(roman, index))); } } return sum; } private  RomanConverter(); }
RomanConverter { static int convertRomanToArabicNumber(String roman) { roman = roman.toUpperCase(); int sum = 0; int current = 0; int previous = 0; for (int index = roman.length() - 1; index >= 0; index--) { if (doesSymbolsContainsRomanCharacter(roman, index)) { current = getSymbolValue(roman, index); if (current < previous) { sum -= current; } else { sum += current; } previous = current; } else { throw new IllegalArgumentException( String.format("Invalid roman character %s ", getCharValue(roman, index))); } } return sum; } private  RomanConverter();  }
RomanConverter { static int convertRomanToArabicNumber(String roman) { roman = roman.toUpperCase(); int sum = 0; int current = 0; int previous = 0; for (int index = roman.length() - 1; index >= 0; index--) { if (doesSymbolsContainsRomanCharacter(roman, index)) { current = getSymbolValue(roman, index); if (current < previous) { sum -= current; } else { sum += current; } previous = current; } else { throw new IllegalArgumentException( String.format("Invalid roman character %s ", getCharValue(roman, index))); } } return sum; } private  RomanConverter();   }