コード例 #1
0
        static void Main(string[] args)
        {
            var calculator = new TimeCalculator();

            while (true)
            {
                Iterate(calculator);
            }
        }
コード例 #2
0
        private static void Iterate(TimeCalculator calculator)
        {
            try
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                var input = ReadString("Enter expression: ");
                if (string.IsNullOrWhiteSpace(input))
                {
                    return;
                }

                var result = calculator.Evaluate(input);
                Console.WriteLine("{0}:{1}", ((int)result.TotalHours), result.Minutes);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(ex.ToString());
            }
        }