static void Main(string[] args)
        {
            TerminalExpression a = new TerminalExpression(4);
            RootExpression     b = new RootExpression(a);

            Console.WriteLine(b.solve());
        }
        static void Main(string[] args)
        {
            TerminalExpression a = new TerminalExpression(4);
            TerminalExpression b = new TerminalExpression(5);
            AddExpression      c = new AddExpression(a, b);

            Console.WriteLine(c.solve());
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            TerminalExpression a = new TerminalExpression(4);
            NegativeExpression b = new NegativeExpression(a);
            TerminalExpression c = new TerminalExpression(5);
            MultiplyExpression d = new MultiplyExpression(a, b);
            MultiplyExpression e = new MultiplyExpression(a, c);

            Console.WriteLine(d.solve());
            Console.WriteLine(e.solve());
        }
        static void Main(string[] args)
        {
            TerminalExpression  a = new TerminalExpression(4);
            TerminalExpression  b = new TerminalExpression(5);
            TerminalExpression  c = new TerminalExpression(-2);
            TerminalExpression  d = new TerminalExpression(-1);
            SubstractExpression e = new SubstractExpression(a, b);
            SubstractExpression f = new SubstractExpression(a, c);
            SubstractExpression g = new SubstractExpression(c, d);
            SubstractExpression h = new SubstractExpression(c, b);

            Console.WriteLine(e.solve());
            Console.WriteLine(f.solve());
            Console.WriteLine(g.solve());
            Console.WriteLine(h.solve());
        }
        static void Main(string[] args)
        {
            TerminalExpression a   = new TerminalExpression(4);
            NegativeExpression b   = new NegativeExpression(a);
            TerminalExpression c   = new TerminalExpression(5);
            TerminalExpression nol = new TerminalExpression(0);
            DivisionExpression d   = new DivisionExpression(a, b);
            DivisionExpression e   = new DivisionExpression(a, c);
            DivisionExpression f   = new DivisionExpression(c, nol);
            String             text;

            try{
                Console.WriteLine(f.solve());
            } catch (Error err) {
                text = err.printMessage();
                Console.WriteLine(text);
            }
            Console.WriteLine(d.solve());
            Console.WriteLine(e.solve());
        }