private Boolean Tokenizer(string str, IntegerSet set) { foreach (var num in str.Split(',')) { try { set.InsertElement(Int32.Parse(num)); } catch (Exception e) { StatusBoxText = e.Message; return(false); } } return(true); }
/// <summary> /// This function finds the union between two IntegerSet objects and returns the set. /// </summary> /// <param name="otherSet">The other IntegerSet object.</param> /// <returns>The resultant set which contains the union of the two sets.</returns> public IntegerSet Union(IntegerSet otherSet) { IntegerSet resultSet = new IntegerSet(); int counter = 0; foreach (bool value in otherSet.Set) { if (value) { resultSet.Set[counter] = true; } else if (_set[counter]) { resultSet.Set[counter] = true; } counter++; } return(resultSet); }
public void Update() { Restart(); IntegerSet unionSet = new IntegerSet(); IntegerSet intersectionSet = new IntegerSet(); if (Tokenizer(SetOne, setOne) && Tokenizer(SetTwo, setTwo)) { unionSet = setOne.Union(setTwo); UnionText = unionSet.ToString(); intersectionSet = setOne.Intersection(setTwo); IntersectionText = intersectionSet.ToString(); StatusBoxText = "Sets Entered Correctly"; } else { StatusBoxText = "Sets Entered Incorrectly"; } }