示例#1
0
        public INode AddFirstNode()
        {
            List <IOperator> operators = new List <IOperator>();

            Console.WriteLine("\n1.x\n" +
                              "2.skaičių\n" +
                              "3.cos(ax+b)\n" +
                              "4.sin(ax+b)\n" +
                              "5.e^ax+b\n" +
                              "6.ln(ax+b)\n" +
                              "(\n"
                              );
            Console.Write(equation);
            string choice = Console.ReadLine();

            switch (choice)
            {
            case "1":
                AddOperationToNode(CreateX(), operators);
                break;

            case "2":
                AddOperationToNode(CreateNumber(), operators);
                break;

            case "3":
                AddOperationToNode(CreateCosX(), operators);
                break;

            case "4":
                AddOperationToNode(CreateSinX(), operators);
                break;

            case "5":
                AddOperationToNode(CreateEx(), operators);
                break;

            case "6":
                AddOperationToNode(CreateLnX(), operators);
                break;

            case "(":
                equation += "(";
                OpenParenthesis item = new OpenParenthesis(accuracy, riba);
                item.equation = equation;
                var ri = item.AddFirstNode();
                equation = item.equation;
                AddOperationToNode(ri, operators);
                break;

            default:
                Console.WriteLine("nera tokio pasirinkimo");

                break;
            }
            DoOperations s = new DoOperations(operators);

            return(s.SimplifyNodes());
        }
示例#2
0
        public INode AddNode()
        {
            Console.WriteLine("\n1.x\n" +
                              "2.skaičių\n" +
                              "3.cos(ax+b)\n" +
                              "4.sin(ax+b)\n" +
                              "5.e^ax^b\n" +
                              "6.ln(ax+b)\n" +
                              "(\n"
                              );
            Console.Write(equation);
            string choice = Console.ReadLine();

            switch (choice)
            {
            case "1":
                return(CreateX());

            case "2":
                return(CreateNumber());

            case "3":
                return(CreateCosX());

            case "4":
                return(CreateSinX());

            case "5":
                return(CreateEx());

            case "6":
                return(CreateLnX());

            case "(":
                equation += "(";
                OpenParenthesis item = new OpenParenthesis(accuracy, riba);
                item.equation = equation;
                var ri = item.AddFirstNode();
                equation = item.equation;
                return(ri);

            default:
                Console.WriteLine("nera tokio pasirinkimo");

                break;
            }
            return(new X(1, 1));
        }