Exemplo n.º 1
0
        /**
         * method Intersection creates a third set which is the set-theoretic intersection of two existing sets
         * (i.e., an element of the third set’s array is set to false if that element is false in either or both
         * of the existing sets—otherwise, the element of the third set is set to true).
         **/
        public IntegerSet Intersection(IntegerSet set2)
        {
            //creating a temporary integerset object to save the intersection of the two integerSet objects.
            IntegerSet set3 = new IntegerSet();

            //for loop that iterates through all the indexes in the array
            for (int i = 0; i < 101; i++)
            {
                if (set2.GetValue(i) && intSet[i] == true)
                {
                    set3.setValueTrue(i);
                }
                else
                {
                    set3.SetValueFalse(i);
                }
            }
            return(set3);
        }