Exemplo n.º 1
0
        public string AddRomanNumbers(string firstNumber, string secondNumber)
        {
            if (!_inputValidator.CheckIfRomanCharacter(firstNumber))
            {
                return(firstNumber + NotRomanError);
            }
            if (!_inputValidator.CheckIfRomanCharacter(secondNumber))
            {
                return(secondNumber + NotRomanError);
            }

            var firstIntFromRoman = _romanToNumbers.ConvertFromRoman(firstNumber.ToUpper());

            var secondIntFromRoman = _romanToNumbers.ConvertFromRoman(secondNumber.ToUpper());

            var sum = _calculator.AddNumbers(firstIntFromRoman, secondIntFromRoman);

            if (!_inputValidator.RangeValidator(sum))
            {
                return(SumError);
            }

            var romanWord = new StringBuilder();

            romanWord = _romanToNumbers.ConvertToRoman(sum, romanWord);

            return(romanWord.ToString());
        }