示例#1
0
        public void Break(string proposition)
        {
            int openBracket  = 0;
            int closeBracket = 0;

            if (Node is Operator)
            {
                proposition = proposition.Substring(2, proposition.Length - 3);
            }

            for (int i = 0; i < proposition.Length; i++)
            {
                if (proposition[i] == '(')
                {
                    openBracket++;
                }

                if (proposition[i] == ')')
                {
                    closeBracket++;
                }

                if (openBracket == closeBracket && proposition[i] == ',')
                {
                    int split = i;
                    LeftChild  = new Proposition(proposition.Substring(0, split));
                    RightChild = new Proposition(proposition.Substring(split + 1));
                }
            }
        }
示例#2
0
        public Proposition(string proposition)
        {
            try
            {
                //Does not take spaces into consideration
                proposition = proposition.Replace(" ", "");

                char firstCharacter = proposition.First();

                if (IsLetter(firstCharacter))
                {
                    Node = new Operand(firstCharacter);
                }

                if (IsOperator(firstCharacter))
                {
                    Node = new Operator(firstCharacter);
                }

                if (!IsLetter(firstCharacter) && !IsNegation(firstCharacter))
                {
                    Break(proposition);
                }
                else
                {
                    if (IsNegation(firstCharacter))
                    {
                        LeftChild = new Proposition(proposition.Substring(2, proposition.Length - 3));
                    }
                }
            }catch (Exception)
            {
            }
        }
示例#3
0
        public string Proposition(string input)
        {
            input = input.Replace(" ", "");

            PropositionNode = new Proposition(input);
            return(PropositionNode.ToString());
        }