예제 #1
0
        public string Add(RomanNumber rhs)
        {
            var thisInt = this.ToInt();
            var otherInt = rhs.ToInt();

            int result = thisInt + otherInt;
            string resStr = "";

            resStr += this.AddDivisor(10, 'X', ref result);
            resStr += this.AddDivisor(5, 'V', ref result);
            resStr += this.AddDivisor(1, 'I', ref result);

            resStr = resStr.Replace("IIII", "IV");
            return resStr;
        }
예제 #2
0
        public void ConvertsToIntegerCorrectly(string roman, int expectedInt)
        {
            var romanNumber = new RomanNumber(roman);

            Assert.AreEqual(expectedInt, romanNumber.ToInt());
        }