static void Show_objects(ref Dictionary <int, Person> dict, ref int Count_of_objects) { dict = new Dictionary <int, Person>(); Count_of_objects = 1; Console.WriteLine("Объекты класса Person:"); for (int i = 0; i < size; i++) { Person person; bool exists = true; do { person = new Person(names[rnd.Next(0, 12)], rnd.Next(18, 60)); if (!dict.ContainsValue(person)) { exists = false; } } while (exists); ShowAdd(ref dict, person, Count_of_objects); Count_of_objects++; } Console.WriteLine("Объекты класса Student:"); for (int i = 0; i < size; i++) { Student student; bool exists = true; do { student = new Student(names[rnd.Next(0, 12)], rnd.Next(18, 25), rnd.Next(1, 5), rnd.Next(1, 5) + rnd.NextDouble()); if (!dict.ContainsValue(student)) { exists = false; } } while (exists); ShowAdd(ref dict, student, Count_of_objects); Count_of_objects++; } Console.WriteLine("Объекты класса Researcher:"); for (int i = 0; i < size; i++) { Researcher researcher; bool exists = true; do { researcher = new Researcher(names[rnd.Next(0, 12)], rnd.Next(25, 60), posts[rnd.Next(0, 5)]); if (!dict.ContainsValue(researcher)) { exists = false; } } while (exists); ShowAdd(ref dict, researcher, Count_of_objects); Count_of_objects++; } Console.WriteLine("Объекты класса Professor:"); for (int i = 0; i < size; i++) { Professor professor; bool exists = true; do { professor = new Professor(names[rnd.Next(0, 12)], rnd.Next(25, 60), posts[rnd.Next(0, 5)], professor_posts[rnd.Next(0, 5)], departments[rnd.Next(0, 5)]); if (!dict.ContainsValue(professor)) { exists = false; } } while (exists); ShowAdd(ref dict, professor, Count_of_objects); Count_of_objects++; } }