Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace soccerTeam_01
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> teamBarselona;
- List<string> fieldPosition;
- bool exit = false;
- string userInput;
- GetSoccerTeam(out teamBarselona, out fieldPosition);
- while (exit == false)
- {
- Console.WriteLine($"1 - Добавить досье\n2 - Вывести все досье\n3 - Удалить досье\n4 - Выход");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- Console.WriteLine($"Добавление нового игрока\n");
- AddRecords(teamBarselona, fieldPosition);
- break;
- case "2":
- Console.WriteLine($"Футбольный клуб Барселона\n");
- ShowRecords(teamBarselona, fieldPosition);
- break;
- case "3":
- Console.Write($"Для удаления на скамейку запасных введите порядковый номер игрока: ");
- DeleteRecord(teamBarselona, fieldPosition);
- break;
- case "4":
- exit = true;
- break;
- }
- Console.Write($"Нажмите любую клавишу для продолжения");
- Console.ReadKey();
- Console.Clear();
- }
- }
- static void GetSoccerTeam(out List<string> teamBarselona, out List<string> fieldPosition)
- {
- teamBarselona = new List<string>();
- fieldPosition = new List<string>();
- teamBarselona.Add("Френки де Йонг");
- fieldPosition.Add("полузащитник");
- teamBarselona.Add("Лионель Месси");
- fieldPosition.Add("нападающий");
- teamBarselona.Add("Жорди Альба");
- fieldPosition.Add("защитник");
- teamBarselona.Add("Педри");
- fieldPosition.Add("полузащитник");
- teamBarselona.Add("Антуан Гризманн");
- fieldPosition.Add("нападающий");
- teamBarselona.Add("Клеман Лангле");
- fieldPosition.Add("защитник");
- teamBarselona.Add("Серджи Бускетс");
- fieldPosition.Add("полузащитник");
- teamBarselona.Add("Серджиньо Дест");
- fieldPosition.Add("защитник");
- teamBarselona.Add("Оскар Мингеса");
- fieldPosition.Add("защитник");
- teamBarselona.Add("Усман Дембеле");
- fieldPosition.Add("полузащитник");
- teamBarselona.Add("Мартин Брэйтуэйт");
- fieldPosition.Add("нападающий");
- teamBarselona.Add("Нето");
- fieldPosition.Add("вратарь");
- }
- static void ShowRecords(List<string> teamBarselona, List<string> fieldPosition)
- {
- for (int i = 0; i < teamBarselona.Count; i++)
- {
- Console.WriteLine($"{i + 1}. {teamBarselona[i]} - {fieldPosition[i]}");
- }
- }
- static void AddRecords(List<string> teamBarselona, List<string> fieldPosition)
- {
- Console.Write($"Введите ФИО игрока: ");
- string fullName = Console.ReadLine();
- teamBarselona.Add(fullName);
- Console.Write($"Введите позицию на футбольном поле: ");
- string position = Console.ReadLine();
- fieldPosition.Add(position);
- Console.WriteLine($"Добавлена новая запись: {fullName} - {position}");
- }
- static void DeleteRecord(List<string> teamBarselona, List<string> fieldPosition)
- {
- bool readInt = int.TryParse(Console.ReadLine(), out int indexForDelete);
- if (readInt == true)
- {
- if(indexForDelete > 0 && indexForDelete <= teamBarselona.Count)
- {
- string deleteMessage = teamBarselona[indexForDelete - 1] + " " + fieldPosition[indexForDelete - 1];
- teamBarselona.RemoveAt(indexForDelete - 1);
- fieldPosition.RemoveAt(indexForDelete - 1);
- Console.WriteLine($"Игрок {deleteMessage} удален");
- }
- else
- {
- Console.WriteLine($"Число {indexForDelete} вне диапазона");
- }
- }
- else
- {
- Console.WriteLine($"Это не число");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement