コード例 #1
0
        string getRomanDigit(int number)
        {
            string preview = getRomanDigitPreview(number);

            foreach (ReplacementPattern r in ReplacementPatternCatalog.GetInstance().GetAll())
            {
                preview = r.Replace(preview);
            }

            return(preview);
        }
コード例 #2
0
        public int ConvertToNumber(string roman)
        {
            string start  = "";
            string result = roman;

            while (start != result)
            {
                start = result;
                foreach (ReplacementPattern r in ReplacementPatternCatalog.GetInstance().GetAll())
                {
                    result = r.ReverseReplace(result);
                }
            }

            int number = 0;

            foreach (char c in result)
            {
                number += RomansCatalog.GetInstance().GetOne(c).Value;
            }

            return(number);
        }