/// <summary> /// Выполняет 3 задания Лабораторной работы /// (создание 2 списка, копирование...) /// </summary> static void DoThirdExerciseOfLab() { persons1.Clear(); var persons2 = new PersonList(); Console.WriteLine("***Создание двух списков, по три " + "элемента в каждом***\n"); for (int j = 0; j < 3; j++) { persons1.AddPerson(Person.GetRandomPerson()); Thread.Sleep(15); persons2.AddPerson(Person.GetRandomPerson()); Thread.Sleep(15); } ShowTwoLists(persons1, persons2); Console.ReadKey(); Console.WriteLine("***Добавление нового элемента в 1 " + "список***\n"); persons1.AddPerson(Person.GetRandomPerson()); ShowList(persons1); Console.ReadKey(); Console.WriteLine("***Копирование 2го элемента из " + "1 списока во 2ой список***\n"); persons2.AddPerson(persons1.GetPerson(1)); ShowTwoLists(persons1, persons2); Console.ReadKey(); Console.WriteLine("***Удаление 2го элемента из 1 " + "списка***\n"); persons1.DeletePersonIndex(1); ShowTwoLists(persons1, persons2); Console.ReadKey(); Console.WriteLine("***Очищение 2го списка " + "элементов***\n"); persons2.Clear(); ShowTwoLists(persons1, persons2); }
private void TestSerilize() { var personList = new PersonList(); for (var i = 0; i < Maxvalue; i++) { var person = new Person("Zalunin", "Sergey", i); personList.AddPerson(person); } var s = new System.Diagnostics.Stopwatch(); var personStr = JsonObject.Serialise(personList); s.Start(); var personListDes = JsonObject.Deserialise <PersonList>(personStr); var idList = personListDes.personList.Select(per => per._id).ToList(); s.Stop(); foreach (var id in idList) { //Debug.Log(id); Console.Write(id); } Debug.Log("time:" + s.ElapsedMilliseconds); Debug.Log("person:" + personListDes.personList.Count + " [0]: " + personListDes.personList[0]); }
public ActionResult EditingAddNew(Person person) { if (ModelState.IsValid) { list.AddPerson(person); } return(PartialView("_GridViewPartial", list.GetPersons())); }
public void ListObjectHasOneRecord() { PersonList TestList = new PersonList(); string TestData1 = "Lady Madonna"; TestList.AddPerson(TestData1); Assert.True(TestList.GetPersonPrintName(0) == TestData1); }
/// <summary> /// Точка входа в программу /// </summary> /// <param name="args">Параметры</param> static void Main(string[] args) { Console.WindowWidth = 100; Console.WriteLine("Press any key to start..."); Console.WriteLine(); Console.ReadKey(); Console.WriteLine("Generation of 7 random people..."); Console.WriteLine(); Console.ReadKey(); var listOfPersons = new PersonList(); for (int i = 0; i < 7; i++) { listOfPersons.AddPerson(GetRandomPerson.CreateRandomPerson()); } Console.WriteLine("A list of persons has been sucсessfully created!"); Console.ReadKey(); Console.WriteLine(); Console.WriteLine("Randomly generated list:\n"); for (int i = 0; i < listOfPersons.NumberOfPersons; i++) { Console.ReadKey(); Console.WriteLine(listOfPersons.FindByIndex(i).Info); Console.WriteLine(); } Console.ReadKey(); Console.Write("The fourth person in the list is...\n "); switch (listOfPersons.FindByIndex(3)) { case Adult adult: { Console.WriteLine(adult.GoToTheTherapist()); break; } case Child child: { Console.WriteLine(child.GoWatchTiktoks()); break; } } Console.ReadKey(); Console.WriteLine(); Console.Write("Thanks for watching this masterpiece, " + "see you in the next episodes. Press any key to exit..."); Console.WriteLine(); Console.ReadKey(); }
public ActionResult Add(string name, string city, string phone) { PersonList.AddPerson(new Person() { Name = name, City = city, PhoneNumber = phone, }); return(RedirectToAction("Index")); }
/// <summary> /// Точка входа /// </summary> public static void Main(string[] args) { Console.WriteLine("Чтобы начать работу программы " + "нажмите любую кнопку..."); Console.ReadKey(); Console.Write("\nГенерируем список из 7 людей ---> "); var listPersons = new PersonList(); Console.WriteLine("Создан успешно!"); Console.Write("Заполняем списки ---> "); for (int i = 0; i < 7; i++) { listPersons.AddPerson(GetRandomPerson.CreateRandomPerson()); } Console.WriteLine("Заполнены успешно!"); Console.WriteLine("Случайно сгенерированный список:"); Console.WriteLine("\n**********\n"); for (int i = 0; i < listPersons.Size; i++) { Console.WriteLine(listPersons[i].InfoAboutPerson()); Console.WriteLine(); } Console.WriteLine("\n**********\n"); Console.Write("Определим четвертого человека в списке. Это - "); switch (listPersons[3]) { case Adult adult: { Console.Write("взрослый человек."); var person = listPersons[3] as Adult; Console.WriteLine(person.WatchTV()); break; } case Child child: { Console.Write("ребенок."); var person = listPersons[3] as Child; Console.WriteLine(person.TryWatchTV()); break; } } Console.WriteLine(listPersons[3].WhoAmI()); Console.ReadKey(); }
/// <summary> /// Стартовая точка программы /// </summary> /// <param name="args"></param> public static void Main(string[] args) { var spisokFirst = new PersonList(); spisokFirst.AutoFill(3); var spisokSecond = new PersonList(); spisokSecond.AutoFill(3); PersonListConsoleView(spisokFirst, nameof(spisokFirst)); PersonListConsoleView(spisokSecond, nameof(spisokSecond)); Console.ReadKey(); Console.Clear(); Console.WriteLine("Добавление нового человека в список."); spisokFirst.AddPerson(Person.GetRandomPerson()); PersonListConsoleView(spisokFirst, nameof(spisokFirst)); PersonListConsoleView(spisokSecond, nameof(spisokSecond)); Console.ReadKey(); Console.Clear(); Console.WriteLine("Копирование второго человека из" + " первого списка во второй список."); spisokSecond.AddPerson(spisokFirst.GetPersonByIndex(1)); PersonListConsoleView(spisokFirst, nameof(spisokFirst)); PersonListConsoleView(spisokSecond, nameof(spisokSecond)); Console.ReadKey(); Console.Clear(); Console.WriteLine("Удаление второго человека" + "из первого списка."); spisokFirst.DeleteByIndex(1); PersonListConsoleView(spisokFirst, nameof(spisokFirst)); PersonListConsoleView(spisokSecond, nameof(spisokSecond)); Console.ReadKey(); Console.Clear(); Console.WriteLine("Отчистка второго списка."); spisokSecond.Clean(); PersonListConsoleView(spisokFirst, nameof(spisokFirst)); PersonListConsoleView(spisokSecond, nameof(spisokSecond)); Console.ReadKey(); Console.Clear(); var chelovek = EnterPersonKeyboard(); PersonConsoleView(chelovek); Console.ReadKey(); }
static void PersonLibTest() { Job janitor = new Job(100, "janitor", true); Housing housing1 = new Housing(2000, "123 gadeallé", true); Person person1 = new Person("Bill", 31, janitor, housing1); Person person2 = new Person("Bob", 19, janitor, housing1); PersonList personList = new PersonList(); personList.AddPerson(person1); personList.AddPerson(person2); personList.Organize(); foreach (Person element in personList.personList) { Console.WriteLine(element.name + " " + element.age + " " + element.work.name); Console.WriteLine(personList.workDictionary[element.name]); } }
static void Main(string[] args) { bool stop = false; while (stop == false) { Console.Write("Генерация списка из 7 человек: "); for (int i = 0; i < 10; i++) { Thread.Sleep(50); Console.Write("*"); } var personList = new PersonList(); for (int i = 0; i < 7; i++) { personList.AddPerson(RandomPerson.CreateRandomPerson()); } Console.WriteLine("\nСписок успешно сгенерирован!\n\n"); Console.WriteLine("Сгенериованный список: "); for (int i = 0; i < personList.Length; i++) { Console.WriteLine($"№{i + 1} | {personList[i].InfoAboutPerson()}"); } Console.Write("\nЧетвёртый человек в списке - "); if (personList[3] is Adult) { Console.WriteLine("взрослый."); var person = personList[3] as Adult; Console.WriteLine(person.AdultWork()); } else if (personList[3] is Child) { Console.WriteLine("Ребёнок."); var person = personList[3] as Child; Console.WriteLine(person.ChildRelax()); } Console.Write("\nПовторить? [y]: "); if (Console.ReadLine() != "y") { stop = true; } //Console.ReadKey(); } }
public void ListObjectIsSorted() { PersonList TestList = new PersonList(); string TestData1 = "Lady Madonna"; string TestData2 = "Joe Andrew Smith"; string TestData3 = "Apple Fruitcake"; string TestData4 = "Lumpy Lumbah"; string TestData5 = "Donny Dumbo"; TestList.AddPerson(TestData1); TestList.AddPerson(TestData2); TestList.AddPerson(TestData3); TestList.AddPerson(TestData4); TestList.AddPerson(TestData5); TestList.SortList(); Assert.True(TestList.GetPersonPrintName(0) == TestData5); // Dumbo, Donny Assert.True(TestList.GetPersonPrintName(1) == TestData3); // Fruitcake, Apple Assert.True(TestList.GetPersonPrintName(2) == TestData4); // Lumbah, Lumpy Assert.True(TestList.GetPersonPrintName(3) == TestData1); // Madonna, Lady Assert.True(TestList.GetPersonPrintName(4) == TestData2); // Smith, Joe Andrew }
public virtual Person CreatePerson(Transform parentObject, Vector3 position) { // instantiate new gameObject and then position and parent it //this.gameObject.SetActive (false); GameObject new_go = (GameObject)Instantiate(this.gameObject); new_go.transform.position = new Vector3(position.x, this.transform.position.y, position.z); new_go.transform.parent = parentObject; new_go.SetActive(true); //don't forget to set layer new_go.layer = InterfaceController.LAYER_PERSON; // Add to vehicle list PersonList.AddPerson(new_go.GetComponent <Person> ()); return(new_go.GetComponent <Person> ()); }
/// <summary> /// Точка входа /// </summary> /// <param name="args">Аргументы</param> static void Main(string[] args) { var people = new PersonList(); for (int j = 0; j < 7; j++) { people.AddPerson(RandomPerson.CreateRandomPerson()); } ShowList(people); Console.WriteLine("Определение типа 4-го элемента и выполнение " + "какого-нибудь метода:"); FourthPerson(people); Console.ReadKey(); }
/// <summary> /// Точка вхождения. /// </summary> /// <param name="args">Аргументы</param> public static void Main(string[] args) { Console.Write("Генерируем 7 человек..."); var persons = new PersonList(); for (int i = 0; i < 7; i++) { persons.AddPerson(RandomPerson.CreateRandomPerson()); } Console.WriteLine(" Готово!\n\n"); Console.WriteLine("Случайно сгенерированный список:\n"); for (int i = 0; i < persons.Length; i++) { Console.WriteLine(persons[i].FormInfoAboutPerson()); Console.WriteLine(); } Console.Write("Четвертый человек в списке - это "); if (persons[3] is Adult) { Console.WriteLine("взрослый человек!"); var person = persons[3] as Adult; Console.WriteLine(person.Smoke()); } else if (persons[3] is Child) { Console.WriteLine("ребенок!"); var person = persons[3] as Child; Console.WriteLine(person.TryToSmoke()); } Console.WriteLine(persons[3].WhoAmI()); Console.ReadKey(); }
public ParseOrderResult ParseOrder(string orderAsString) { if (Organisation == null) { return(new ParseOrderResult(ParseOrderResultState.OrganisationNotFound)); } ParseOrderResultState state = ParseOrderResultState.OK; List <string> catalogIds = Catalogs.Select(c => c.Id).ToList(); List <string> orderLineArray = orderAsString.Split(',').ToList(); Order order = Order.CreateNew(); //new Order() /* * { * OrganisationId = this.Organisation.Id * };*/ order.OrganisationId = this.Organisation.Id; if (this.Account != null) { order.Account = this.Account; order.AccountId = this.Account.Id; } if (this.Party != null) { order.Party = this.Party; order.PartyId = this.Party.Id; } order.OrderType = OrderType.SalesOrder; order.OrderLines = new List <OrderLine>(); List <ParseOrderLineResult> orderLineResults = new List <ParseOrderLineResult>(); PersonList personList = new PersonList(); int lineNumber = 10; orderLineArray.ForEach(ol => { ParseOrderLineResult orderLineResult = ParseOrderLine(this.Organisation, catalogIds, ol.Trim()); orderLineResults.Add(orderLineResult); if (orderLineResult.State == ParseOrderLineResultState.OK) { if (lineNumber == 10) { //order.TaxIncluded = orderLineResult } var orderLine = orderLineResult.OrderLine; if (!string.IsNullOrWhiteSpace(orderLine.Persons)) { PersonCodes codes = new PersonCodes(orderLine.Persons); foreach (string code in codes.Codes) { if (!personList.Contains(code)) { personList.AddPerson(new Person(code, code)); } } } orderLine.Order = order; orderLine.LineNumber = lineNumber; order.OrderLines.Add(orderLine); if (orderLine.Product.NeedsPlanning) { order.IsAppointment = true; } lineNumber += 10; } else { state = ParseOrderResultState.AtLeastOneProblem; } }); order.Persons = personList.ToString(); order.NrOfPersons = personList.Persons.Count; ParseOrderResult result = new ParseOrderResult(order, state); result.OrderLineResults = orderLineResults; return(result); }
/// <summary> /// Точка входа в программу /// </summary> /// <param name="args">Параметры</param> public static void Main(string[] args) { Console.WriteLine("Press any key to start..."); Console.WriteLine(); Console.ReadKey(); Console.WriteLine("Step 1. Two lists of persons are creating, " + "each contains three persons..."); Console.WriteLine(); Console.ReadKey(); var listOne = new PersonList(); var listTwo = new PersonList(); var arrayOne = new Person[] { new Person("Bender", "Rodriguez", 40, Sex.Male), new Person("Philip junior", "Fry", 28, Sex.Male), new Person("Sean", "Diaz", 10, Sex.Female), }; var arrayTwo = new Person[] { new Person("Eric", "Cartman", 12, Sex.Male), new Person("albus-severus", "Potter", 11, Sex.Male), new Person("Bojack", "Horseman", 50, Sex.Male), }; listOne.AddArrayOfPeople(arrayOne); listTwo.AddArrayOfPeople(arrayTwo); Console.WriteLine("Two lists of persons have been sucсessfully created!"); Console.ReadKey(); Console.WriteLine(); Console.WriteLine("Step 2. Displaying the contents of " + "each list to the console..."); ShowListOfPersons(listOne, listTwo); Console.WriteLine(); Console.WriteLine("Step 3. Adding a new person to the first list... "); listOne.AddPerson(new Person("Doctor", "Zoidberg", 98, Sex.Male)); ShowListOfPersons(listOne, listTwo); Console.WriteLine(); Console.WriteLine("A new person has been successfully added" + " to the first list!"); Console.ReadKey(); Console.WriteLine(); Console.WriteLine("Step 4. Copying the second person from the first" + " list to the end of the second list... "); listTwo.AddPerson(listOne.FindByIndex(1)); ShowListOfPersons(listOne, listTwo); Console.WriteLine(); Console.WriteLine("Now the same person is on both lists!"); Console.WriteLine(); Console.ReadKey(); Console.WriteLine("Step 5. Removing the second person from the first list..."); listOne.DeleteByIndex(1); ShowListOfPersons(listOne, listTwo); Console.WriteLine(); Console.WriteLine("Removing a person from the 1st list did not " + "delete the same person in the 2nd list!"); Console.WriteLine(); Console.ReadKey(); Console.WriteLine("Step 6. Clearing the second list..."); listTwo.DeleteAllPeople(); ShowListOfPersons(listOne, listTwo); Console.WriteLine("All persons have been successfully removed from the 2nd list!"); Console.WriteLine(); Console.ReadKey(); Console.WriteLine("Step 7. Let's add a new person " + "to the second list from keyboard..."); Console.WriteLine(); listTwo.AddPerson(AddConsolePerson.NewPerson()); ShowListOfPersons(listOne, listTwo); Console.WriteLine(); Console.WriteLine("Step 8. Add a random person " + "to the second list..."); Person randPerson = RandomPerson.GetRandomPerson(); listTwo.AddPerson(randPerson); ShowListOfPersons(listOne, listTwo); Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
/// <summary> /// Точка входа /// </summary> public static void Main() { Console.WriteLine("Чтобы начать работу программы " + "нажмите любую кнопку..."); Console.ReadKey(); Console.Write("\nСоздаем списки людей ---> "); var designDepartOne = new PersonList(); var designDepartTwo = new PersonList(); Console.WriteLine("Созданы успешно!"); Console.Write("Заполняем списки ---> "); var peopleForListOne = new Person[] { new Person("Андрей", "Гришенков", 24, SexTypes.Male), new Person("Ванадий", "Ванадьев", 29, SexTypes.Male), new Person("Борис", "Борисенко", 21, SexTypes.Male) }; var peopleForListTwo = new Person[] { new Person("Юлия", "Шишко", 35, SexTypes.Female), new Person("Григорий", "Терешков", 31, SexTypes.Male), new Person("Лилия", "Сюдзенко", 24, SexTypes.Female) }; designDepartOne.AddRangeOfPersons(peopleForListOne); designDepartTwo.AddRangeOfPersons(peopleForListTwo); Console.WriteLine("Заполнены успешно!"); PrintPersonList(designDepartOne, designDepartTwo); Console.Write("Добавляем нового человека в первый список ---> "); var newDesignerDepartOne = new Person("Кирилл", "Ананьев", 34, SexTypes.Male); designDepartOne.AddPerson(newDesignerDepartOne); Console.WriteLine("Добавлен успешно!"); PrintPersonList(designDepartOne, designDepartTwo); Console.WriteLine("Копируем второго человека из " + "первого списка во второй ---> "); designDepartTwo.AddPerson(designDepartOne[1]); Console.WriteLine("Скопирован успешно!\n"); PrintPersonList(designDepartOne, designDepartTwo); Console.WriteLine("Удаляем второго человека" + " из первого списка ---> "); designDepartOne.DelPersonByIndex(1); Console.WriteLine("Удален успешно!"); PrintPersonList(designDepartOne, designDepartTwo); Console.Write("Очищаем второй список ---> "); designDepartTwo.Clear(); Console.WriteLine("Очищен успешно!"); PrintPersonList(designDepartOne, designDepartTwo); Console.Write("Добавляем во второй список " + "случайного человека ---> "); designDepartTwo.AddPerson(GetRandomPerson.ReceiveRandomPerson()); Console.WriteLine("Добавлен успешно!"); PrintPersonList(designDepartOne, designDepartTwo); Console.WriteLine("Добавим человека, получая параметры " + "от пользователя..."); designDepartTwo.AddPerson(PersonInput.CreateNewPerson()); PrintPersonList(designDepartOne, designDepartTwo); Console.Write("Чтобы завершить работу нажмите любую кнопку..."); Console.ReadKey(); }
/// <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; } } }
public IActionResult Create([FromBody] Person item) { _context.AddPerson(item); //call AddPerson() method from PersonList return(CreatedAtRoute("GetPerson", new { id = item.Id }, item)); // return a route to the new person added }