Ejemplo n.º 1
0
        static void Main(string[] args)

        {
            Mnoj first  = new Mnoj();
            Mnoj second = new Mnoj();

            Console.WriteLine(first.Equals(second));
            first.Equals(second);
            first.Add(2);
            first.Connect(second);
            first.Search(1);
            first.Show();

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public override bool Equals(Object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            Mnoj temp = obj as Mnoj;//проверка на принадлежность классу Equila

            if (mnojestvo.Length != temp.mnojestvo.Length)
            {
                return(false);
            }
            for (int i = 0; i < mnojestvo.Length; i++)
            {
                if (mnojestvo[i] != temp.mnojestvo[i])
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public void Connect(Mnoj mnoj)
        {
            bool check;

            int[] arr = mnojestvo;
            for (int i = 0; i < mnoj.mnojestvo.Length; i++)
            {
                check = true;
                for (int j = 0; j < arr.Length; j++)
                {
                    if (mnoj.mnojestvo[i] == arr[j])
                    {
                        check = false;
                    }
                }
                if (check)
                {
                    Array.Resize(ref arr, arr.Length + 1);
                    arr[arr.Length - 1] = mnoj.mnojestvo[i];
                }
            }
            Array.Sort(arr);
            mnojestvo = arr;
        }