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(); }
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); }
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; }