Exemplo n.º 1
0
 //Определение типа
 void WhatType()
 {
     if (term[0] == '(')
     {
         type = TypeOfPart.openBracket;
     }
     if (term[0] == ')')
     {
         type = TypeOfPart.closeBracket;
     }
     if (IsOperation(term))
     {
         type = TypeOfPart.operation;
     }
     if (IsNumber(term))
     {
         type = TypeOfPart.number;
     }
     if (IsFunction(term))
     {
         type = TypeOfPart.function;
     }
     else if (IsVariable(term))
     {
         type = TypeOfPart.variable;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">Type of part that you need</param>
 public SourcePartDefault(TypeOfPart type)
 {
     if (type == TypeOfPart.Adjective)
     {
         strings = Resources.Adjectives.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
     }
     else if (type == TypeOfPart.Noun)
     {
         strings = Resources.Nouns.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)?.ToList();
     }
 }
Exemplo n.º 3
0
        public bool IsRightFunction()
        {
            TypeOfPart current     = parts[0].ttype;
            int        am_brackets = 0;

            if ((current == TypeOfPart.closeBracket) && (parts[0].Term != "-"))
            {
                return(false);
            }
            if (current == TypeOfPart.openBracket)
            {
                am_brackets++;
            }
            int[] u = new int[56];
            for (int i = 1; i < parts.Length; i++)
            {
                switch (parts[i].ttype)
                {
                case TypeOfPart.number:
                case TypeOfPart.variable:
                case TypeOfPart.function:
                    if (current == TypeOfPart.openBracket || current == TypeOfPart.operation)
                    {
                        current = parts[i].ttype;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case TypeOfPart.operation:
                    if (current == TypeOfPart.variable || current == TypeOfPart.number || current == TypeOfPart.closeBracket)
                    {
                        current = parts[i].ttype;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case TypeOfPart.openBracket:
                    am_brackets++;
                    if (current == TypeOfPart.operation || current == TypeOfPart.function || current == TypeOfPart.openBracket)
                    {
                        current = parts[i].ttype;
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case TypeOfPart.closeBracket:
                    am_brackets--;
                    if (current == TypeOfPart.number || current == TypeOfPart.variable || current == TypeOfPart.closeBracket)
                    {
                        current = parts[i].ttype;
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }
            }
            if (am_brackets != 0)
            {
                return(false);
            }
            if (current == TypeOfPart.operation || current == TypeOfPart.function || current == TypeOfPart.openBracket)
            {
                return(false);
            }
            return(true);
        }