Exemple #1
0
        public object Clone()
        {
            TruthTableValues clone = new TruthTableValues();

            foreach (KeyValuePair <string, List <string> > kvp in this)
            {
                clone.Add(kvp.Key, kvp.Value.ToList());
            }
            return(clone);
        }
Exemple #2
0
        private IPrefixExpression NormalizeTable(TruthTableValues tableValues)
        {
            var            resultData      = tableValues[tableValues.Keys.Last()];
            Stack <string> normalizedValue = new Stack <string>();

            for (int i = 0; i < resultData.Count; i++)
            {
                if (normalizedValue.Count > 0)
                {
                    normalizedValue.Push("|(" + normalizedValue.Pop());
                }
                if (resultData[i] == "1")
                {
                    Stack <string> currentRowNormalized = new Stack <string>();
                    var            rowValues            = tableValues.GetRowValuesWithouthResultColumn(i);
                    for (int j = 0; j < rowValues.Count; j++)
                    {
                        if (rowValues[j] != $@"{QuineMcCluskey.DONT_CARE}")
                        {
                            var value = rowValues[j] == "0" ? @$ "~({tableValues.Keys.ElementAt(j)})" : $@"{tableValues.Keys.ElementAt(j)}";
                            if (currentRowNormalized.Count > 0)
                            {
                                currentRowNormalized.Push($@"&({currentRowNormalized.Pop()},{value})");
                            }
                            else
                            {
                                currentRowNormalized.Push(value);
                            }
                        }
                    }
                    if (normalizedValue.Count > 0)
                    {
                        normalizedValue.Push(normalizedValue.Pop() + "," + currentRowNormalized.Pop() + ")");
                    }
                    else
                    {
                        normalizedValue.Push(currentRowNormalized.Pop());
                    }
                }
            }
            return(new PrefixExpression(normalizedValue.Pop()));
        }
Exemple #3
0
 public TruthTable(TruthTableValues Value)
 {
     this.Value = Value;
 }