public void setLabelandRowValue(ProcessLogicClass logicProposition, out char[] truthTableLabel, out List <char[]> truthTableLogicValue) { string raw = logicProposition.getRawString(); truthTableLogicValue = new List <char[]>(); //remove all special characters from the truth table to get the number of logic proposition var charToCut = new string[] { "(", ")", ",", "&", "|", ">", "=", "~", "%" }; foreach (var c in charToCut) { raw = raw.Replace(c, string.Empty); } //sort the string, remove repetition then convert it to an array. This will be the label truthTableLabel = String.Concat(raw.OrderBy(c => c).Distinct()).ToCharArray(); //Setup Row for the truth table int num = truthTableLabel.Length; List <int> RowNumber = new List <int>(); for (int i = 0; i < Math.Pow(2, num); i++) { RowNumber.Add(i); } foreach (int i in RowNumber) { char[] eachRow = Convert.ToString(i, 2).PadLeft(num, '0').ToCharArray(); truthTableLogicValue.Add(eachRow); } }
public void calculateLogic() { foreach (char[] charArray in ValuesEachLine) { string rawString = logicProposition.getRawString(); for (int i = 0; i < label.Length; i++) { rawString = rawString.Replace(label[i], charArray[i]); } ProcessLogicClass processTable = new ProcessLogicClass(rawString); bool result = processTable.getProposition().CalculateFinalTruthValue(); results.Add(Convert.ToInt32(result)); } }