Пример #1
0
        public override string Evaluate()
        {
            string valueOne = ExpressionOne.ToString();
            string valueTwo = ExpressionTwo.ToString();
            string result   = "";

            if (CanEvaluate())
            {
                if (valueOne != null && valueTwo != null)
                {
                    if (add)
                    {
                        result = valueOne + valueTwo;
                        return(result);
                    }
                    else
                    {
                        return("");
                    }
                }
                else
                {
                    string errorMsg = valueOne + " + " + valueTwo;


                    FormControlWindow.TerminalWriteLine("La condition ( " + errorMsg + " ) est impossible.");
                    return("");
                }
            }
            else
            {
                return("");
            }
        }
Пример #2
0
        public override bool Execute()
        {
            if (!Subprogram.VarExists(VarName, ParentSubprogram))
            {
                if (inputValue)
                {
                    VarValue = Subprogram.PromptInputValue <string>();
                }

                if (VarValue != null)
                {
                    ParentSubprogram.ListVar.Add(new StringVar(VarName, VarValue));
                }
                else
                {
                    Error    = true;
                    ErrorMsg = "Variable " + VarName + " ne peut pas être égal à NULL.";
                }
            }
            else
            {
                Error    = true;
                ErrorMsg = "Variable " + VarName + " existe déjà.";
            }

            if (!Error)
            {
                return(true);
            }
            else
            {
                FormControlWindow.TerminalWriteLine("VarError : " + ErrorMsg);
                return(false);
            }
        }
Пример #3
0
        public override bool Evaluate()
        {
            int?   valueOne = AlgorithmicExpression.CalculExpression(ExpressionOne, ParentSubprogram);
            int?   valueTwo = AlgorithmicExpression.CalculExpression(ExpressionTwo, ParentSubprogram);
            bool   result   = false;
            string errorMsg;

            if (CanEvaluate())
            {
                if (valueOne != null && valueTwo != null)
                {
                    if (IsEgal)
                    {
                        result = valueOne == valueTwo;
                    }
                    else if (IsBigger)
                    {
                        result = valueOne > valueTwo;
                    }
                    else if (IsSmaller)
                    {
                        result = valueOne < valueTwo;
                    }

                    if (IsNot)
                    {
                        return(!result);
                    }
                    else
                    {
                        return(result);
                    }
                }
                else
                {
                    if (IsEgal)
                    {
                        errorMsg = valueOne + " = " + valueTwo;
                    }
                    else if (IsBigger)
                    {
                        errorMsg = valueOne + " > " + valueTwo;
                    }
                    else
                    {
                        errorMsg = valueOne + " < " + valueTwo;
                    }

                    FormControlWindow.TerminalWriteLine("La condition ( " + errorMsg + " ) est impossible.");
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        public override bool Execute()
        {
            if (CanExecute())
            {
                if ((Var = ParentSubprogram.GetVar(varToken.GetImage(), ParentSubprogram)) == null)
                {
                    Error    = true;
                    ErrorMsg = "Variable " + varToken.GetImage() + " n'existe pas.";
                }

                if (!Error)
                {
                    if (Var is IntVar intVar)
                    {
                        if (inputValue)
                        {
                            intVar.SetValue(Subprogram.PromptInputValue <int>());
                        }
                        else
                        {
                            intVar.SetValue(AlgorithmicExpression.CalculExpression(SetVarValue.GetChildAt(0), ParentSubprogram));
                        }
                    }
                    else if (Var is StringVar stringVar)
                    {
                        if (inputValue)
                        {
                            stringVar.SetValue(Subprogram.PromptInputValue <string>());
                        }
                        else
                        {
                            stringVar.SetValue(AlgorithmicExpression.CalculStringExpression(SetVarValue.GetChildAt(0), ParentSubprogram));
                        }
                    }
                    return(true);
                }
                else
                {
                    FormControlWindow.TerminalWriteLine("VarError : " + ErrorMsg);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        public override bool Execute()
        {
            if (CanExecute())
            {
                if (inputValue)
                {
                    Value = Subprogram.PromptInputValue <string>();
                }
                else
                {
                    Value = AlgorithmicExpression.CalculStringExpression(stringExpression, ParentSubprogram);
                }

                if (Value != null && IsStringValue == true)
                {
                    FormControlWindow.TerminalWriteLine("Fourmi dit : " + Value);
                    return(true);
                }
                else
                {
                    if (VarName != null && IsStringValue == false)
                    {
                        if ((Value = Subprogram.VarToString(VarName, ParentSubprogram)) == null)
                        {
                            ErrorMsg = "Variable " + VarName + " n'existe pas.";
                        }
                        else
                        {
                            FormControlWindow.TerminalWriteLine("Fourmi dit : " + Value);
                            return(true);
                        }
                    }
                }
            }

            FormControlWindow.TerminalWriteLine("DireError : " + ErrorMsg);
            return(false);
        }