Esempio n. 1
0
        // <summary>
        /// To  do union of the two set.
        /// </summary>

        public IntegerSet Union(object obj)
        {
            IntegerSet tempSet = new IntegerSet();


            for (int i = 0; i < this.set.Length; i++)
            {
                if (this.set[i] == true || (obj as IntegerSet).set[i] == true)
                {
                    tempSet.set[i] = true;
                }
            }



            return(tempSet);
        }
Esempio n. 2
0
        // <summary>
        /// To  do intersection of the two set.
        /// </summary>
        public IntegerSet Intersection(object obj)
        {
            IntegerSet tempSet = new IntegerSet();

            for (int i = 0; i < this.set.Length; i++)
            {
                if (this.set[i] == true && (obj as IntegerSet).set[i] == true)
                {
                    tempSet.set[i] = true;
                }
                else
                {
                    tempSet.set[i] = false;
                }
            }
            return(tempSet);
        }
Esempio n. 3
0
        } // end Main

        // creates a new set by reading numbers from the user
        public static IntegerSet InputSet()
        {
            IntegerSet temp = new IntegerSet();

            Console.Write("Enter number (-1 to end): ");
            int number = Convert.ToInt32(Console.ReadLine());

            while (number != -1)
            {
                temp.InsertElement(number);

                Console.Write("Enter number (-1 to end): ");
                number = Convert.ToInt32(Console.ReadLine());
            } // end while

            return(temp);
        }