Esempio n. 1
0
        //Correcting all it can / should
        public string Correct(string par)
        {
            List <char> ret = new List <char>();

            par = Normalize(par);

            for (int i = 0; i < par.Length; i++)
            {
                if (ArrayLib.Contains(NUMBERS, par[i]))
                {
                    ret.Add(par[i]);
                }
                else if (ArrayLib.Contains(OPERATORS, par[i]))
                {
                    ret.Add(par[i]);
                }
                else if (ArrayLib.Contains(PARANTHESES, par[i]))
                {
                    ret.Add(par[i]);
                }
            }

            par = new string(ret.ToArray());
            par = AddParanthesesMultiplicator(par);
            return(par);
        }
Esempio n. 2
0
        //Checking for errors

        public bool Validate(string param)
        {
            if (!(ArrayLib.Count(param.ToCharArray(), '(') == ArrayLib.Count(param.ToCharArray(), ')')))
            {
                Prog.ThrowError(1);
                return(false);
            }
            for (int i = 0; i < param.Length; i++)
            {
                if (ArrayLib.Contains(OPERATORS, param[i]) && ArrayLib.Contains(OPERATORS, param[i + 1]))
                {
                    Prog.ThrowError(0);
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 3
0
 public ElementType GetElementType(char element)
 {
     if (ArrayLib.Contains(OPERATORS, element))
     {
         return(ElementType.Operator);
     }
     else if (ArrayLib.Contains(NUMBERS, element))
     {
         return(ElementType.Number);
     }
     else if (ArrayLib.Contains(PARANTHESES, element))
     {
         return(ElementType.Parantheses);
     }
     else
     {
         return(ElementType.None);
     }
 }