コード例 #1
0
 // TRUTH TABLE
 public bool CheckTruthSign()
 {
     if (Node is Operand)
     {
         return(Node.Boolean);
     }
     else
     {
         if (Node.NodeValue == '~')
         {
             return(!LeftChild.CheckTruthSign());
         }
         else
         {
             if (Node.NodeValue == '>')
             {
                 return(!LeftChild.CheckTruthSign() || RightChild.CheckTruthSign());
             }
             else if (Node.NodeValue == '=')
             {
                 return(LeftChild.CheckTruthSign() == RightChild.CheckTruthSign());
             }
             else if (Node.NodeValue == '&')
             {
                 return(LeftChild.CheckTruthSign() && RightChild.CheckTruthSign());
             }
             else if (Node.NodeValue == '|')
             {
                 return(LeftChild.CheckTruthSign() || RightChild.CheckTruthSign());
             }
             else if (Node.NodeValue == '%')
             {
                 return(!(LeftChild.CheckTruthSign() && RightChild.CheckTruthSign()));
             }
             else
             {
                 throw new ArgumentException("Ups, you did something wrong!");
             }
         }
     }
 }