コード例 #1
0
ファイル: Form1.cs プロジェクト: BasJoosten98/Logic-app
        private bool createAllConHoldersAndTruthtables(string proposition)
        {
            try
            {
                //CREATING PROPOSITION
                Connective con = PropositionReader.ReadPropositionString(proposition);

                if (con.IsNormalProposition())
                {
                    conHolder = new ConnectiveHolder(con);
                    table     = new Truthtable(conHolder);
                    printDisjunctive();

                    conHolderDisjunctive = new ConnectiveHolder(tbDisjunctiveParse.Text);
                    tableDisjunctive     = new Truthtable(conHolderDisjunctive);

                    conHolderDisjunctiveSimple = new ConnectiveHolder(tbDisjunctiveSimpleParse.Text);
                    tableDisjunctiveSimple     = new Truthtable(conHolderDisjunctiveSimple);

                    conHolderNand = conHolder.GetNandHolder();
                    tableNand     = new Truthtable(conHolderNand);

                    conHolderNandSimple = conHolderDisjunctiveSimple.GetNandHolder();
                    tableNandSimple     = new Truthtable(conHolderNandSimple);

                    tbInfix.Text      = conHolder.GetInfixString();
                    tbNand.Text       = conHolderNand.GetParseString();
                    tbNandSimple.Text = conHolderNandSimple.GetParseString();
                    showTableauxTree  = false;

                    //DRAWING AND PRINTING TABLE INFORMATION
                    printVisualTruthtables(table);
                    printTablesInformation();
                }
                else
                {
                    if (!con.AreLocalArgumentsMatching(new List <char>(), new List <char>()))
                    {
                        throw new Exception("Local Arguments are mismatching or there are quantifiers with the same Local Argument");
                    }
                    conHolder        = new ConnectiveHolder(con);
                    tbInfix.Text     = conHolder.GetInfixString();
                    showTableauxTree = false;
                }
                Console.WriteLine("Succesfully parsed proposition: " + proposition);
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Parsing failed: please make sure that you wrote a proposition");
                Console.WriteLine("Failed to parse proposition: " + proposition);
                return(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Parsing failed: " + ex.Message);
                Console.WriteLine("Failed to parse proposition: " + proposition);
                return(false);
            }
            return(true);
        }
コード例 #2
0
 public override bool AreLocalArgumentsMatching(List <char> LocalArguments, List <char> LocalArgumentsAll)
 {
     return(con1.AreLocalArgumentsMatching(LocalArguments, LocalArgumentsAll));
 }