public static void Main() { ResearchTeamCollection <string> researchTeamCollection = new ResearchTeamCollection <string>(team => team.Name); researchTeamCollection.AddDefaults(10); var testResTeam1 = new ResearchTeam("ResName***", "CompName***", 912, "Teammy", TimeFrame.TwoYears); var testResTeam2 = new ResearchTeam("ResName___", "CompName___", 912, "Turner", TimeFrame.TwoYears); testResTeam1.AddPapers(new Paper("B", new Person("Andrew", "Garfield", new DateTime(1985, 1, 21)), new DateTime(2020, 1, 10))); testResTeam1.AddPapers(new Paper("C", new Person("Santa", "Claus", new DateTime(1985, 1, 21)), new DateTime(2019, 1, 10))); testResTeam1.AddPapers(new Paper("A", new Person("Pavel", "Morozov", new DateTime(1985, 1, 21)), new DateTime(2018, 1, 10))); testResTeam2.AddPapers(new Paper("A", new Person(), new DateTime(2021, 2, 6))); testResTeam2.AddPapers(new Paper("A", new Person(), new DateTime(2019, 2, 6))); testResTeam2.AddPapers(new Paper("A", new Person(), new DateTime(2018, 2, 6))); researchTeamCollection.AddResearchTeams(testResTeam1, testResTeam2); //1 Console.WriteLine("Статьи отсортированные по дате: "); foreach (var item in testResTeam1.SortArticlesByDate()) { Console.WriteLine(item); } Console.WriteLine("\nСтатьи отсортированы по названию: "); foreach (var item in testResTeam1.SortByArticleName()) { Console.WriteLine(item); } Console.WriteLine("\nСтатьи отсортированы по фамилии автора: "); foreach (var item in testResTeam1.SortByAuthorSurname()) { Console.WriteLine(item); } //2 var tTeam1 = new ResearchTeam("OOO", "Comp___Name", 122, "Troover", TimeFrame.Year); var tTeam2 = new ResearchTeam("FFF", "Comp_-_Name", 93, "CatDog", TimeFrame.Year); tTeam1.AddPapers(new Paper("FirstPaper", new Person("Andrew", "Garfield", new DateTime(1985, 1, 21)), new DateTime(2020, 5, 10))); tTeam2.AddPapers(new Paper("SecondPaper", new Person(), new DateTime(2021, 1, 6))); ResearchTeamCollection <string> strTeamCollection = new ResearchTeamCollection <string>(team => team.Name); strTeamCollection.AddResearchTeams(tTeam1, tTeam2, testResTeam1, testResTeam2); Console.WriteLine("\nResTeam<string>:"); Console.WriteLine(strTeamCollection); //3 Console.WriteLine("Дата выхода последней статьи"); Console.WriteLine(strTeamCollection.LatestArticleDate); Console.WriteLine("\nКоманды с продолжительностью исследования год:"); foreach (var item in strTeamCollection.TimeFrameGroup(TimeFrame.Year)) { Console.WriteLine(item.Value.ToShortString()); } Console.WriteLine("\nГруппировка элементов по длительности исследований: "); foreach (var group in strTeamCollection.DurationGroups) { Console.WriteLine("\nГруппа с продолжительностью " + group.Key); foreach (var item in group) { Console.WriteLine(item.Value.ToShortString()); } } //4 int elCount = 0;// = 1000000; while (true) { try { Console.Write("Введите кол-во элементов: "); elCount = Int32.Parse(Console.ReadLine()); if (elCount <= 0) { Console.WriteLine("Число должно быть положительным! Повторите ввод"); continue; } break; } catch (FormatException) { Console.WriteLine("Ошибка при вводе числа! Повторите ввод"); } catch (OverflowException) { Console.WriteLine("Число слишком большое! Повторите ввод"); } } TestCollections testCollection = new TestCollections(elCount); List <Team> lst = testCollection.GetTeamList(); Console.WriteLine("\nВремя для первого элемента: \n"); PrintTime(lst[0], testCollection); Console.WriteLine("\nВремя для элемента в середине: \n"); PrintTime(lst[lst.Count / 2], testCollection); Console.WriteLine("\nВремя для элемента в конце: \n"); PrintTime(lst[lst.Count - 1], testCollection); Console.WriteLine("\nВремя для элемента которого нет: \n"); PrintTime(new Team("GG", 123321, "321"), testCollection); }
static void Main(string[] args) { Console.WindowWidth = 170; //1 ResearchTeamCollection teamCollection = new ResearchTeamCollection(); Random random = new Random(); for (int i = 0; i < 5; i++) { teamCollection.AddResearchTeams(TestCollections.GenElement(random.Next(1000))); } teamCollection.AddResearchTeams(new ResearchTeam("ResName***", "CompName***", 912, "Teammy", TimeFrame.TwoYears)); teamCollection.AddResearchTeams(new ResearchTeam("ResName___", "CompName___", 912, "Turner", TimeFrame.TwoYears)); Console.WriteLine(teamCollection); //2 Console.WriteLine("\nСортировка по номеру лицензии"); foreach (var item in teamCollection.GetSortedByLicenceList()) { Console.WriteLine(item.ToShortString()); } Console.WriteLine("\nСортировка по названию исследований"); foreach (var item in teamCollection.GetSortedByResearchNameList()) { Console.WriteLine(item.ToShortString()); } Console.WriteLine("\nСортировка по числу публикаций"); foreach (var item in teamCollection.GetSortedByArticlesCount()) { Console.WriteLine(item.ToShortString() + "Кол-во статей: " + item.ArticleList.Count); } //3 Console.WriteLine("\nМинимальная лицензия: " + teamCollection.MinLicenceNumber); Console.WriteLine("\nИсследования с сроком 2 года: "); foreach (var item in teamCollection.TwoYearResearchTeams) { Console.WriteLine(item); } Console.WriteLine("\nГруппировка по кол-ву объектов"); foreach (var group in teamCollection.GetResTeamList().GroupBy(team => team.ArticleList.Count)) { Console.WriteLine("\nГруппа №" + group.Key); foreach (var item in group) { Console.WriteLine(item.ToShortString() + "Кол-во статей: " + item.ArticleList.Count); } } //4 int elCount = 0;// = 1000000; while (true) { try { Console.Write("Введите кол-во элементов: "); elCount = Int32.Parse(Console.ReadLine()); if (elCount <= 0) { Console.WriteLine("Число должно быть положительным! Повторите ввод"); continue; } break; } catch (FormatException) { Console.WriteLine("Ошибка при вводе числа! Повторите ввод"); } catch (OverflowException) { Console.WriteLine("Число слишком большое! Повторите ввод"); } } TestCollections testCollection = new TestCollections(elCount); List <Team> lst = testCollection.GetTeamList(); Console.WriteLine("\nВремя для первого элемента: \n"); PrintTime(lst[0], testCollection); Console.WriteLine("\nВремя для элемента в середине: \n"); PrintTime(lst[lst.Count / 2], testCollection); Console.WriteLine("\nВремя для элемента в конце: \n"); PrintTime(lst[lst.Count - 1], testCollection); }
static void Main(string[] args) { StudentCollection collection = new StudentCollection(); Person person1 = new Person("Ernar", "Kadyrbekov", new DateTime(1999, 1, 21)); Person person2 = new Person("Roman", "Krit", new DateTime(1998, 11, 1)); Person person3 = new Person("French", "Montana", new DateTime(1998, 2, 6)); Person person4 = new Person("Fifty", "Cent", new DateTime(2000, 2, 13)); Student student1 = new Student(person1, Education.Bachelor, 302); Student student2 = new Student(person2, Education.Bachelor, 302); Student student3 = new Student(person3, Education.Bachelor, 302); Student student4 = new Student(person4, Education.Bachelor, 302); student1.Tests = new System.Collections.Generic.List <Test> { new Test("Calculus", true), new Test("Algebra", true), new Test("Differential Equations", true) }; student2.Tests = new System.Collections.Generic.List <Test> { new Test("Calculus", true), new Test("Algebra", true), new Test("Differential Equations", true) }; student3.Tests = new System.Collections.Generic.List <Test> { new Test("Calculus", true), new Test("Algebra", true), new Test("Differential Equations", true) }; student4.Tests = new System.Collections.Generic.List <Test> { new Test("Calculus", true), new Test("Algebra", true), new Test("Differential Equations", true) }; student1.Exams = new System.Collections.Generic.List <Exam> { new Exam("JavaScript", 77, new DateTime(2020, 1, 31)), new Exam("Web-Design", 95, new DateTime(2020, 1, 28)), new Exam("Economics", 81, new DateTime(2020, 1, 25)) }; student2.Exams = new System.Collections.Generic.List <Exam> { new Exam("JavaScript", 77, new DateTime(2020, 1, 31)), new Exam("Web-Design", 95, new DateTime(2020, 1, 28)), new Exam("Economics", 81, new DateTime(2020, 1, 25)) }; student3.Exams = new System.Collections.Generic.List <Exam> { new Exam("JavaScript", 77, new DateTime(2020, 1, 31)), new Exam("Web-Design", 95, new DateTime(2020, 1, 28)), new Exam("Economics", 81, new DateTime(2020, 1, 25)) }; student4.Exams = new System.Collections.Generic.List <Exam> { new Exam("JavaScript", 77, new DateTime(2020, 1, 31)), new Exam("Web-Design", 95, new DateTime(2020, 1, 28)), new Exam("Economics", 81, new DateTime(2020, 1, 25)) }; Student[] students = new Student[4]; students[0] = student1; students[1] = student2; students[2] = student3; students[3] = student4; collection.AddStudents(students); Console.WriteLine(collection.ToString() + "\n"); collection.SurnameSort(); Console.WriteLine(collection.ToString() + "\n"); collection.DateOfBirthSort(); Console.WriteLine(collection.ToString() + "\n"); collection.AverageMarkSort(); Console.WriteLine(collection.ToString() + "\n"); Console.WriteLine(collection.MaxAverageMark + "\n"); Console.WriteLine(collection.Master.Cast <object>().ToList().ToString() + "\n"); Console.WriteLine(collection.AverageMarkGroup(80).ToString() + "\n"); List <Person> people = new List <Person>() { person1, person2, person3, person4 }; List <string> vs = new List <string>() { "Ernar", "Roman", "French", "Fifty" }; Dictionary <Person, Student> pairs = new Dictionary <Person, Student>(); pairs.Add(person1, student1); pairs.Add(person2, student2); pairs.Add(person3, student3); pairs.Add(person4, student4); Dictionary <string, Student> pairs1 = new Dictionary <string, Student>(); pairs1.Add("Ernar", student1); pairs1.Add("Roman", student2); pairs1.Add("French", student3); pairs1.Add("Fifty", student4); TestCollections test = new TestCollections(people, vs, pairs, pairs1); test.CheckTimePersonList(0); test.CheckTimePersonList(2); test.CheckTimePersonList(4); test.CheckTimePersonList(7); Console.WriteLine(); test.CheckTimeStringList(0); test.CheckTimeStringList(2); test.CheckTimeStringList(4); test.CheckTimeStringList(7); Console.WriteLine(); test.CheckTimeDictionaryPersonKey(person1); test.CheckTimeDictionaryPersonKey(person3); test.CheckTimeDictionaryPersonValue(student1); test.CheckTimeDictionaryPersonValue(student3); Console.WriteLine(); test.CheckTimeDictionaryStringKey("Ernar"); test.CheckTimeDictionaryStringKey("French"); test.CheckTimeDictionaryStringKey("Fifty"); Console.WriteLine(); test.CheckTimeDictionaryStringValue(student1); test.CheckTimeDictionaryStringValue(student3); Console.WriteLine(); }
static void Main(string[] args) { StudentCollection collection = new StudentCollection(); Person person1 = new Person("Serhiy", "Pityk", new DateTime(2000, 3, 27)); Person person2 = new Person("Artem", "Shtefanesa", new DateTime(1999, 2, 10)); Person person3 = new Person("Ksenia", "Dolgan", new DateTime(1999, 12, 26)); Person person4 = new Person("Margarita", "Boiko", new DateTime(2000, 3, 23)); Person person5 = new Person("Irina", "Zhizhiyan", new DateTime(2000, 5, 25)); Student student1 = new Student(person1, Education.Bachelor, 302); Student student2 = new Student(person2, Education.Bachelor, 302); Student student3 = new Student(person3, Education.Bachelor, 302); Student student4 = new Student(person4, Education.Bachelor, 302); Student student5 = new Student(person5, Education.Bachelor, 302); student1.Testss = new System.Collections.Generic.List <Test> { new Test("Math", true), new Test("History", true), new Test("Philosophy", true) }; student2.Testss = new System.Collections.Generic.List <Test> { new Test("Math", true), new Test("History", true), new Test("Philosophy", true) }; student3.Testss = new System.Collections.Generic.List <Test> { new Test("Math", true), new Test("History", true), new Test("Philosophy", true) }; student4.Testss = new System.Collections.Generic.List <Test> { new Test("Math", true), new Test("History", true), new Test("Philosophy", true) }; student5.Testss = new System.Collections.Generic.List <Test> { new Test("Math", true), new Test("History", true), new Test("Philosophy", true) }; student1.Examss = new System.Collections.Generic.List <Exam> { new Exam("Programming", 85, new DateTime(2020, 4, 20)), new Exam("Structures", 70, new DateTime(2020, 4, 15)), new Exam("Methods", 80, new DateTime(2020, 4, 10)) }; student1.Examss = new System.Collections.Generic.List <Exam> { new Exam("Programming", 80, new DateTime(2020, 4, 20)), new Exam("Structures", 70, new DateTime(2020, 4, 15)), new Exam("Methods", 70, new DateTime(2020, 4, 10)) }; student1.Examss = new System.Collections.Generic.List <Exam> { new Exam("Programming", 70, new DateTime(2020, 4, 20)), new Exam("Structures", 70, new DateTime(2020, 4, 15)), new Exam("Methods", 75, new DateTime(2020, 4, 10)) }; student1.Examss = new System.Collections.Generic.List <Exam> { new Exam("Programming", 75, new DateTime(2020, 4, 20)), new Exam("Structures", 75, new DateTime(2020, 4, 15)), new Exam("Methods", 70, new DateTime(2020, 4, 10)) }; student1.Examss = new System.Collections.Generic.List <Exam> { new Exam("Programming", 100, new DateTime(2020, 4, 20)), new Exam("Structures", 100, new DateTime(2020, 4, 15)), new Exam("Methods", 100, new DateTime(2020, 4, 10)) }; Student[] students = new Student[5]; students[0] = student1; students[1] = student2; students[2] = student3; students[3] = student4; students[4] = student5; collection.AddStudents(students); Console.WriteLine(collection.ToString()); Console.WriteLine(); collection.SurnameSort(); Console.WriteLine(collection.ToString()); Console.WriteLine(); collection.BirthDateSirt(); Console.WriteLine(collection.ToString()); Console.WriteLine(); collection.AverageMarkSort(); Console.WriteLine(collection.ToString()); Console.WriteLine(); Console.WriteLine(collection.MaxAverageMark); Console.WriteLine(collection.Master.Cast <object>().ToList().ToString()); Console.WriteLine(collection.AverageMarkGroup(80).ToString()); List <Person> people = new List <Person>() { person1, person2, person3, person4, person5 }; List <string> vs = new List <string>() { "Serhiy", "Artem", "Ksenia", "Margarita", "Irina" }; Dictionary <Person, Student> pairs = new Dictionary <Person, Student>(); pairs.Add(person1, student1); pairs.Add(person2, student2); pairs.Add(person3, student3); pairs.Add(person4, student4); pairs.Add(person5, student5); Dictionary <string, Student> pairs1 = new Dictionary <string, Student>(); pairs1.Add("Serhiy", student1); pairs1.Add("Artem", student2); pairs1.Add("Ksenia", student3); pairs1.Add("Margarita", student4); pairs1.Add("Irina", student5); TestCollections test = new TestCollections(people, vs, pairs, pairs1); test.CheckTimePersonList(0); Console.WriteLine(); test.CheckTimePersonList(2); Console.WriteLine(); test.CheckTimePersonList(4); Console.WriteLine(); test.CheckTimePersonList(7); Console.WriteLine(); test.CheckTimeStringList(0); Console.WriteLine(); test.CheckTimeStringList(2); Console.WriteLine(); test.CheckTimeStringList(4); Console.WriteLine(); test.CheckTimeStringList(7); Console.WriteLine(); test.CheckTimeDictionaryPersonKey(person1); Console.WriteLine(); test.CheckTimeDictionaryPersonKey(person3); Console.WriteLine(); test.CheckTimeDictionaryPersonKey(person5); Console.WriteLine(); test.CheckTimeDictionaryPersonValue(student1); Console.WriteLine(); test.CheckTimeDictionaryPersonValue(student3); Console.WriteLine(); test.CheckTimeDictionaryPersonValue(student5); Console.WriteLine(); test.CheckTimeDictionaryStringKey("Serhiy"); Console.WriteLine(); test.CheckTimeDictionaryStringKey("Ksenia"); Console.WriteLine(); test.CheckTimeDictionaryStringKey("Irina"); Console.WriteLine(); test.CheckTimeDictionaryStringValue(student1); Console.WriteLine(); test.CheckTimeDictionaryStringValue(student3); Console.WriteLine(); test.CheckTimeDictionaryStringValue(student5); Console.WriteLine(); }