private void CalculateButt_Click(object sender, EventArgs e) { try { if (UnionRad.Checked) { if (!InfixBox.Text.Equals("")) { String infix = InfixBox.Text; String posfix = Postfix.ConvertToPostFix(infix); ArraySet res = UnionAndIntersResult(posfix); ResultBox.Text = res.toString(); } } if (PowerSetRad.Checked) { ArraySet res = UnionAndIntersResult(Postfix.ConvertToPostFix(InfixBox.Text)); ResultBox.Text = ArraySet.getPowerSet(res); } if (SubSetRad.Checked) { String expression = InfixBox.Text; String temp = ""; ArraySet temp1 = null; ArraySet temp2; foreach (char i in expression.ToCharArray()) { if (i == 'c') { temp1 = UnionAndIntersResult(Postfix.ConvertToPostFix(temp)); temp = ""; } else { temp += i; } } temp2 = UnionAndIntersResult(Postfix.ConvertToPostFix(temp)); ResultBox.Text = Convert.ToString(ArraySet.isSubsetOf(temp1, temp2)); } if (CartesianRad.Checked) { String expression = InfixBox.Text; expression = expression.Replace('(', ' '); expression = expression.Replace(')', ' '); expression = expression.Replace('x', ' '); int count = 0; foreach (char i in expression.ToArray()) { if (getIndexFromChar(i) != -1) { count++; } } ArraySet[] tempSetList = new ArraySet[count]; count = 0; foreach (char i in expression.ToArray()) { if (getIndexFromChar(i) != -1) { tempSetList[count] = setList[getIndexFromChar(i)]; if (tempSetList[count].size() == 0) { ResultBox.Text = "Error : Cartesian product with an empty set"; return; } count++; } } ResultBox.Text = ArraySet.Cartesian(tempSetList); } }catch (Exception ex) { MessageBox.Show("Error : Incorrect Input" + " : " + ex.Message); } }