/// <summary> /// Точка вхождения. /// </summary> /// <param name="args">Аргументы</param> public static void Main(string[] args) { Console.WriteLine("Для начала работы программы " + "нажмите любую клавишу..."); Console.ReadKey(); Console.Write("\nСоздаем списки людей... "); var artists = new PersonList(); var actors = new PersonList(); Console.WriteLine("Успешно!"); Console.Write("Заполняем списки людей... "); var peopleForFirstList = new Person[] { new Person("Danzel", "Curry", 35, Genders.Male), new Person("Ariana", "Grande", 29, Genders.Female), new Person("Kendrick", "Lamar", 33, Genders.Male) }; var peopleForSecondList = new Person[] { new Person("Tom", "Hanks", 63, Genders.Male), new Person("Jim", "Carrey", 57, Genders.Male), new Person("Jennifer", "Aniston", 50, Genders.Female) }; artists.AddRange(peopleForFirstList); actors.AddRange(peopleForSecondList); Properties.Resources.gavno = "gen"; PrintEndStrings(); PrintLists(artists, actors); Console.Write("Добавляем нового человека в первый список... "); var newArtist = new Person("Kid", "Cudi", 35, Genders.Male); artists.AddPerson(newArtist); PrintEndStrings(); Console.Write("Копируем второго человека из " + "первого списка во второй... "); actors.AddPerson(artists[1]); Console.WriteLine("Успешно!\n"); PrintLists(artists, actors); Console.Write("Удаляем второго человека из первого списка... "); artists.DeletePersonByIndex(1); Console.WriteLine("Успешно!"); PrintLists(artists, actors); Console.Write("Очищаем второй список... "); actors.Clear(); PrintEndStrings(); Console.Write( "Добавляем во второй список случайного человека... "); actors.AddPerson(RandomPerson.CreateRandomPerson()); Console.WriteLine("Успешно!"); Console.WriteLine( "Добавим человека, получая параметры от пользователя..."); actors.AddPerson(IOConsole.CreateNewPerson()); PrintLists(artists, actors); Console.Write("Для завершения работы нажмите любую кнопку..."); Console.ReadKey(); }
/// <summary> /// Main program /// </summary> /// <param name="args">Arguments</param> static void Main(string[] args) { Console.WriteLine("Press any key to create lists "); Console.ReadKey(); Console.Write("\nCreating lists... "); var listOne = new PersonList(); var listTwo = new PersonList(); var firstList = new Person[] { new Person("Зohn", "Do-e", 45, Gender.Male), new Person("Billy", "Herrington", 48, Gender.Male), new Person("Lisa", "Su", 50, Gender.Female), }; var secondList = new Person[] { new Person("Robert", "Swan", 59, Gender.Male), new Person("Van", "Darkholme", 47, Gender.Male), new Person("Fo-o", "Bar", 34, Gender.Female), }; listOne.AddRange(firstList); listTwo.AddRange(secondList); Console.WriteLine("\nLists have been created. " + "Press any key to display the lists."); Console.ReadKey(); Console.WriteLine(); PrintLists(listOne, listTwo); bool flag = true; while (flag) { PrintMenu(); switch (ExceptionHandler()) { case 1: Console.WriteLine("Adding a new person " + "programmatically..."); var newEntry = new Person("Rick", "Astley", 54, Gender.Male); listOne.AddPerson(newEntry); Console.WriteLine("Successful!"); Console.WriteLine("Press Y to show list, any key " + "to go back to the menu."); char key = Console.ReadKey().KeyChar; if (key == 'y' || key == 'н') { PrintLists(listOne); } break; case 2: Console.WriteLine("Which index whould you like " + "to copy?"); listTwo.AddPerson(ExceptionHandler(firstList)); SuccessfulMethod(); PrintLists(listOne, listTwo); break; case 3: Console.WriteLine("Which index whould you like " + " to delete?"); listOne.DeletePersonByIndex(IndexExceptionHandler (firstList)); SuccessfulMethod(); PrintLists(listOne, listTwo); break; case 4: listOne.AddPerson(RandomPerson.PickPerson()); SuccessfulMethod(); PrintLists(listOne); break; case 5: listTwo.Clear(); SuccessfulMethod(); PrintLists(listOne, listTwo); break; case 6: listOne.AddPerson(CreateNewPerson()); PrintLists(listOne, listTwo); break; case 0: flag = false; break; default: TryAgain(); break; } } }