コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        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";
            }
        }