} // end Main /// <summary> /// InputSet functions gets user input for elements to add to a newly created IntegerSet /// <returns>Returns the newly created IntegerSet object</returns> /// </summary> public static IntegerSet InputSet() { IntegerSet set = new IntegerSet(); while (true) { Console.WriteLine("Please enter your set elements one at a time (to quit enter q): "); input = Console.ReadLine(); if (input.Equals("q")) { break; } value = Convert.ToInt32(input); set.InsertElement(value); } return(set); }
/// <summary> /// Union function creates a new IntegerSet and makes it the union of two other sets /// <param name="set">An IntegerSet object that the union function takes as input</param> /// <returns>Returns the newly created union IntegerSet object</returns> /// </summary> public IntegerSet Union(IntegerSet set) { IntegerSet union = new IntegerSet(); for (int i = 0; i <= 100; i++) { if (array[i] == true || set.array[i] == true) { union.array[i] = true; } else { union.array[i] = false; } } return(union); }
/// <summary> /// Intersection function creates a new IntegerSet and makes it the intersection of two other sets /// <param name="set">An IntegerSet object that the intersection function takes as input</param> /// <returns>Returns the newly created intersection IntegerSet object</returns> /// </summary> public IntegerSet Intersection(IntegerSet set) { IntegerSet intersection = new IntegerSet(); for (int i = 0; i <= 100; i++) { if (array[i] == false || set.array[i] == false) { intersection.array[i] = false; } else { intersection.array[i] = true; } } return(intersection); }
/// <summary> /// IsEqualTo function takes another IntegerSet object to compare if they are equal using built in SequenceEqual function /// <param name="b">An IntegerSet object we compare our IntegerSet to for equality</param> /// <returns>Returns a boolean value that indicates whether they are equal (true) or not (false)</returns> /// </summary> public bool IsEqualTo(IntegerSet b) { bool equal = array.SequenceEqual(b.array); return(equal); }