Пример #1
0
        public void Theory6To12Conversion(int arabic, string roman)
        {
            var engine = new RomanEngine();

            Assert.Equal(roman, engine.Convert(arabic));
            Assert.Equal(arabic, engine.Convert(roman));
        }
Пример #2
0
        public void TheoryRandomConversion(int arabic, string roman)
        {
            var engine = new RomanEngine();

            roman = roman.Replace("^", RomanEngine.Macron);
            Assert.Equal(roman, engine.Convert(arabic));
            Assert.Equal(arabic, engine.Convert(roman));
        }
Пример #3
0
        static void Main(string[] args)
        {
            var engine = new RomanEngine();

            Console.WriteLine("I convert Decimals to Roman Numerals and vice versa.");
            Console.Write("Enter one or the other: ");
            var input  = Console.ReadLine();
            var output = string.Empty;

            while (input.ToLower() != "exit")
            {
                output = int.TryParse(input, out var result)
                    ? engine.Convert(result)
                    : engine.Convert(input.ToUpper()).ToString();
                Console.WriteLine($"'{input.ToUpper()}' converted is '{output}'");
                Console.Write("Enter a Roman Numeral or a Decimal (exit to leave): ");
                input = Console.ReadLine();
            }
            Console.WriteLine("Thankyou for using the Roman Numeral Converter...");
        }