public void processEachLine_returnValidOrNot()
        {
            //Arrange
            ProcessLogicClass processObject    = new ProcessLogicClass("=(>(a,b),c)");
            TruthTable        truthTableObject = new TruthTable(processObject);
            List <char[]>     ValuesAllLines   = truthTableObject.returnValuesEachLine();
            List <int>        allResults       = truthTableObject.returnLogicResult();

            //Act
            DNF    DNFobject = new DNF(allResults, ValuesAllLines, new String(truthTableObject.returnLabel()));
            string toReturn  = DNFobject.processEachLine("001", "abc");

            //Assert
            Assert.AreEqual(toReturn, "&(&(~(a),~(b)),c)");
        }
        public void processAllLines_TestOutputContradiction()
        {
            //Arrange
            ProcessLogicClass processObject    = new ProcessLogicClass("&(&(B,=(>(|(=(A,B),C),>(~(=(A,B)),>(A,>(A,B)))),~(B))),~(D))");
            TruthTable        truthTableObject = new TruthTable(processObject);
            List <char[]>     ValuesAllLines   = truthTableObject.returnValuesEachLine();
            List <int>        allResults       = truthTableObject.returnLogicResult();

            //Act
            DNF    DNFobject = new DNF(allResults, ValuesAllLines, new String(truthTableObject.returnLabel()));
            string dnfString = DNFobject.returnDNFString();

            //Assert
            Assert.AreEqual(dnfString, "Cannot generate a DNF with a contradiction!");
        }
        public void processAllLines_TestOutPutTrue()
        {
            //Arrange
            ProcessLogicClass processObject    = new ProcessLogicClass("=(>(a,b),c)");
            TruthTable        truthTableObject = new TruthTable(processObject);
            List <char[]>     ValuesAllLines   = truthTableObject.returnValuesEachLine();
            List <int>        allResults       = truthTableObject.returnLogicResult();

            //Act
            DNF    DNFobject = new DNF(allResults, ValuesAllLines, new String(truthTableObject.returnLabel()));
            string dnfString = DNFobject.returnDNFString();

            //Assert
            Assert.AreEqual(dnfString, "|(|(|(&(&(~(a),~(b)),c),&(&(~(a),b),c)),&(&(a,~(b)),~(c))),&(&(a,b),c))");
        }
        public void returnDNFString_checkIfNull()
        {
            //Arrange
            ProcessLogicClass processObject    = new ProcessLogicClass("=(>(a,b),c)");
            TruthTable        truthTableObject = new TruthTable(processObject);
            List <char[]>     ValuesAllLines   = truthTableObject.returnValuesEachLine();
            List <int>        allResults       = truthTableObject.returnLogicResult();
            DNF DNFobject = new DNF(allResults, ValuesAllLines, new String(truthTableObject.returnLabel()));

            //Act
            string dnfString = DNFobject.returnDNFString();

            //Assert
            Assert.IsNotNull(dnfString);
        }
        public void GenerateListForDNF_testIfSuccess()
        {
            //Arrange
            ProcessLogicClass processObject    = new ProcessLogicClass("=(>(a,b),c)");
            TruthTable        truthTableObject = new TruthTable(processObject);
            List <char[]>     ValuesAllLines   = truthTableObject.returnValuesEachLine();
            List <int>        allResults       = truthTableObject.returnLogicResult();
            DNF DNFobject = new DNF(allResults, ValuesAllLines, new String(truthTableObject.returnLabel()));

            //Act
            List <string> GenerateListForDNFReturn = DNFobject.GenerateListForDNF(allResults, ValuesAllLines);

            //Assert
            Assert.IsNotNull(GenerateListForDNFReturn);
        }
        public void GetNANDString_test_output_is_it_valid()
        {
            //Arrange
            ProcessLogicClass processObject    = new ProcessLogicClass(">(a,b)");
            TruthTable        truthTableObject = new TruthTable(processObject);
            List <char[]>     ValuesAllLines   = truthTableObject.returnValuesEachLine();
            List <int>        allResults       = truthTableObject.returnLogicResult();
            DNF DNFobject = new DNF(allResults, ValuesAllLines, new String(truthTableObject.returnLabel()));

            //Act
            string result = processObject.GetNANDString(DNFobject.returnDNFString());

            //Assert
            Assert.AreEqual(result, "%(~(%(~(~(%(~(a),~(b)))),~(~(%(~(a),b))))),~(~(%(a,b))))");
        }
Beispiel #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ AvgLifeTimeOfPlayer.GetHashCode();
         hashCode = (hashCode * 397) ^ DNF.GetHashCode();
         hashCode = (hashCode * 397) ^ (FlexibleStats?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Player?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (PostMatchRatings?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (PreMatchRatings?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Rank;
         hashCode = (hashCode * 397) ^ TeamId;
         return(hashCode);
     }
 }
        private void BuildNormalFormsClick(object sender, EventArgs e)
        {
            DNF.Clear();
            CNF.Clear();

            if (n == 0)
            {
                textBox2.Text = "Для начала постройте таблицу истинности!";
            }
            else
            {
                bool tavt = true, otr = true;

                for (var i = 1; i < h; i++)
                {
                    if (table[i, w - 1] == "1")
                    {
                        if (DNF.Text != "")
                        {
                            DNF.Text += " ⋁ ";
                        }

                        for (var j = 1; j <= varNames.Count; j++)
                        {
                            if (table[i, j] == "0")
                            {
                                DNF.Text += "¬" + table[0, j];
                            }
                            else
                            {
                                DNF.Text += table[0, j];
                            }
                        }

                        tavt = false;
                    }
                }

                if (tavt)
                {
                    textBox2.Text =
                        "Данное логическое выражение является отрицанием. Поэтому построить СДНФ невозможно";
                }

                for (var i = 1; i < h; i++)
                {
                    if (table[i, w - 1] == "0")
                    {
                        if (CNF.Text != "")
                        {
                            CNF.Text += " ⋀ (";
                        }
                        else
                        {
                            CNF.Text += "(";
                        }

                        var f = true;

                        for (var j = 1; j <= varNames.Count; j++)
                        {
                            if (!f)
                            {
                                CNF.Text += " ⋁ ";
                            }

                            if (table[i, j] == "1")
                            {
                                CNF.Text += "¬" + table[0, j];
                            }
                            else
                            {
                                CNF.Text += table[0, j];
                            }

                            f = false;
                        }

                        CNF.Text += ")";
                        otr       = false;
                    }
                }

                if (otr)
                {
                    textBox2.Text =
                        "Данное логическое выражение является тавтологией. Поэтому построить СКНФ невозможно";
                }

                if (!otr && !tavt)
                {
                    textBox2.Text = "СДНФ и СКНФ успешно построены!";
                }
            }
        }