static void Main(string[] args)
        {
            String    expression = "w x z - +";
            Evaluator sentence   = new Evaluator(expression);
            Dictionary <String, IExpression> variables = new Dictionary <String, IExpression>();

            variables.Add("w", new Number(5));
            variables.Add("x", new Number(10));
            variables.Add("z", new Number(42));
            int result = sentence.Interpret(variables);

            Console.WriteLine(result);
        }
        static void Main(string[] args)
        {
            CalculatorContext context = new CalculatorContext();

            context.Input = "12 3 6 / *";

            var evaluator = new Evaluator(context);

            context.Output = evaluator.Interpret(new Dictionary <string, IExpression>());
            Console.WriteLine(context.Output);

            Console.ReadKey();
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     Console.WriteLine("Digite a expressão com 3 variaveis (w, x e z)");
     String expression = Console.ReadLine();
     Evaluator sentence = new Evaluator(expression);
     Dictionary<String,Expression> variables = new Dictionary<String,Expression>();
     Console.WriteLine("w=");
     variables.Add("w", new Number(Convert.ToInt32(Console.ReadLine())));
     Console.WriteLine("x=");
     variables.Add("x", new Number(Convert.ToInt32(Console.ReadLine())));
     Console.WriteLine("z=");
     variables.Add("z", new Number(Convert.ToInt32(Console.ReadLine())));
     int result = sentence.Interpret(variables);
     Console.WriteLine(result);
     Console.ReadKey();
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Digite a expressão com 3 variaveis (w, x e z)");
            String    expression = Console.ReadLine();
            Evaluator sentence   = new Evaluator(expression);
            Dictionary <String, Expression> variables = new Dictionary <String, Expression>();

            Console.WriteLine("w=");
            variables.Add("w", new Number(Convert.ToInt32(Console.ReadLine())));
            Console.WriteLine("x=");
            variables.Add("x", new Number(Convert.ToInt32(Console.ReadLine())));
            Console.WriteLine("z=");
            variables.Add("z", new Number(Convert.ToInt32(Console.ReadLine())));
            int result = sentence.Interpret(variables);

            Console.WriteLine(result);
            Console.ReadKey();
        }