private static void TestCondition() { do { Console.Clear(); Console.Write("Введите выражение с условным оператором: "); string expression = Console.ReadLine(); List <string> polishExpression = PolishCondition.GetPolishNote(expression); Console.Write("\nВыражение в обратной польской нотации: "); foreach (string s in polishExpression) { Console.Write(s + " "); } Console.WriteLine(); string result = PolishCondition.CalculatePolishExpression(polishExpression); Console.WriteLine("\nРезультат вычисления: " + result); PolishArithmetic.SetVars(); foreach (KeyValuePair <string, string> p in PolishArithmetic.Vars) { Console.WriteLine(p.Key + " = " + p.Value); } PolishArithmetic.Vars.Clear(); Console.WriteLine("\n(Нажмите ESC, чтобы выйти)"); }while (Console.ReadKey().Key != ConsoleKey.Escape); }
private static void TestArithmetic() { do { Console.Clear(); Console.Write("Введите арифметическое выражение: "); string expression = Console.ReadLine(); string convertedExpression = PolishArithmetic.GetPolishNotation(expression); Console.WriteLine("\nВыражение в обратной польской нотации: {0}", convertedExpression); string result = PolishArithmetic.CalculatePolishExpression(convertedExpression); Console.Write("\nРезультат вычисления: "); if (!Char.IsLetter(result[0])) { Console.Write(result); } Console.WriteLine(); PolishArithmetic.SetVars(); foreach (KeyValuePair <string, string> p in PolishArithmetic.Vars) { Console.WriteLine(p.Key + " = " + p.Value); } PolishArithmetic.Vars.Clear(); Console.WriteLine("\n(Нажмите ESC, чтобы выйти)"); }while (Console.ReadKey().Key != ConsoleKey.Escape); }