Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //by Vegas
- using System.Collections;
- namespace LearnRSUE
- {
- class Player
- {
- public string Name { get; set; }
- public string Skill { get; set; }
- public string Age { get; set; }
- }
- class Program
- {
- static void Main()
- {
- List<Player> players = new List<Player>(); // Создаем лист
- int s = 0, id = 0, NY = 0;
- while (s != -1) // Для зацикливания
- {
- Console.Write("\nВыберите действие(0 - добавить игрока, 1 - просмотр команды, -1 - выйти, 2 - поиск по амплуа): ");
- s = Convert.ToInt32(Console.ReadLine());
- switch (s)
- {
- case 0: // Новый игрок
- Console.Write("Имя: ");
- string name = Console.ReadLine();
- Console.Write("Возраст: ");
- string age = Console.ReadLine();
- Console.Write("Амплуа: ");
- string skill = Console.ReadLine();
- players.Add(new Player { Name = name, Skill = skill, Age = age });
- break;
- case 1: // Вывод игроков
- foreach (var item in players)
- {
- if (Convert.ToInt32(item.Age) > 18)
- {
- NY++;
- }
- }
- Console.WriteLine();
- for (int i = 0; i < players.Count; i++)
- {
- Console.WriteLine((i+1) + ")" +
- " Имя: " + players[i].Name + ";" +
- " Амплуа: " + players[i].Skill + ";" +
- " Возраст: " + players[i].Age);
- }
- Console.WriteLine("\nКол - во игроков старше 18: " + NY);
- break;
- case -1: // Выход
- s = -1;
- break;
- case 2: // Поиск по амплуа
- int score = 0;
- Console.Write("Введите амплуа: ");
- string amplua = Console.ReadLine();
- foreach (var item in players)
- {
- if (item.Skill == amplua)
- {
- score++;
- }
- }
- Console.WriteLine("\nКол-во игроков с ампула " + amplua + ": " + score);
- break;
- default:
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement