示例#1
0
 void Observer()
 {
     if (Checker.isNumberDeclaration(givenExpression) && !Checker.ifContainOperations(givenExpression))
     {
         MakeNumber();
     }
     else if (Checker.isMatrixDeclaration(givenExpression) && !Checker.ifContainMatOperations(givenExpression) && Checker.isMinusIncludedInMatrix(givenExpression))
     {
         MakeMatrix();
     }
     else
     {
         if (Checker.ifContainOperations(givenExpression))                       // if the expression is a mathematical one.
         {
             EquationHead.EquationWatch theEquationSolution = new EquationHead.EquationWatch(theExpressionList, givenExpression);
             if (theEquationSolution.isProcessed())
             {
                 theResult = new Expression(theEquationSolution.getSolution());
                 if (theResult.getExpType() == 1)
                 {
                     theResult.setEntireTag(autoMatrixNamer());
                 }
                 else if (theResult.getExpType() == 2)
                 {
                     theResult.setEntireTag(autoNumberNamer());
                 }
                 Processed = true;
             }
             else
             {
                 Processed = false;
             }
         }
         else if (!Checker.ifPrefixExist(givenExpression) && !Checker.isConstant(givenExpression) && SearchList(givenExpression))                          // for searching a quried variable
         {
             Processed = false;
         }
         else if (!Checker.ifPrefixExist(givenExpression) && Checker.isConstant(givenExpression))
         {
             Processed = false;
             ExpressionPrinter p = new ExpressionPrinter(theConstantList.getConstant(givenExpression));
             p.Print();
         }
         else if (Checker.ifPrefixExist(givenExpression))
         {
             Processed = false;
             ExpressionPrinter p = new ExpressionPrinter(pUnderstander.prefixList(givenExpression));
             p.Print();
         }
         else
         {
             TheMessageHandler.MessagePrinter.Print("Variable does not exist");
             Processed = false;
         }
     }
 }
示例#2
0
        //________________________________________________________//

        // this observes the equation being given... i.e it sees if is mathematical equation
        // or a variable declaration.
        // or if the command is invalid

        void Obeserver()
        {
            Breaker();
            if (Checker.ifContainOperations(LHS) || LHS.Contains(" ") || string.IsNullOrWhiteSpace(LHS) || Checker.isNumeric(LHS [0]))
            {
                // if left hand side is and equation or some thing else than a single variable or if it is and empty
                //string or its first character is a number
                TheMessageHandler.MessagePrinter.Print("Wrong format LHS cannot contain an expression");
                Processed = false;
            }
            else
            {
                if (!Checker.ifContainOperations(RHS) && Checker.isNumberDeclaration(RHS))                     // if the string is a Numeric Declaration.
                {
                    NumberMaker();
                }
                else if (!Checker.ifContainOperations(RHS) && Checker.isMatrixDeclaration(RHS))                       // if the string is a Matrix Declaration.
                {
                    MatrixMaker();
                }
                else
                {
                    if (SearchList(RHS))                           // THIS DEALS WITH THE REASSIGNMENT LIKE A = B
                    {
                        Reassignment();
                    }
                    else
                    {
                        if (Checker.ifContainOperations(RHS))
                        {
                            EquationHead.EquationWatch solution = new EquationHead.EquationWatch(theExpressionList, RHS);
                            if (solution.isProcessed())
                            {
                                result = new Expression(solution.getSolution());
                                result.setTag(LHS);
                                Processed = true;
                            }
                            else
                            {
                                Processed = false;
                            }
                        }
                        else
                        {
                            Processed = false;
                            TheMessageHandler.MessagePrinter.Print($"No variable '{RHS}' eixsts, currently");
                        }
                    }
                }  //if the is no matrix or number declaration
            }      // else for the reason if there is some thing in the string
        }          // end observer.
示例#3
0
 void Observer()
 {
     if (Checker.isNumberDeclaration(givenExpression) && !Checker.ifContainOperations(givenExpression))
     {
         MakeNumber();
     }
     else if (Checker.isMatrixDeclaration(givenExpression) && !Checker.ifContainOperations(givenExpression))
     {
         MakeMatrix();
     }
     else
     {
         if (Checker.ifContainOperations(givenExpression))                   // if the expression is a mathematical one.
         {
             EquationHead.EquationWatch theEquationSolution = new EquationHead.EquationWatch(theExpressionList, givenExpression);
             if (theEquationSolution.isProcessed())
             {
                 theResult = new Expression(theEquationSolution.getSolution());
                 if (theResult.getExpType() == 1)
                 {
                     theResult.setTag(autoMatrixNamer());
                 }
                 else if (theResult.getExpType() == 2)
                 {
                     theResult.setTag(autoNumberNamer());
                 }
                 Processed = true;
             }
             else
             {
                 Processed = false;
             }
         }
         else if (SearchList(givenExpression))                    // for searching a quried variable
         {
             Processed = false;
         }
         else
         {
             TheMessageHandler.MessagePrinter.Print("Does not exit");
             Processed = false;
         }
     }
 }