Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- const string AddPlayerCommand = "1";
- const string BanPlayerCommand = "2";
- const string UnbanPlayerCommand = "3";
- const string RemovePlayerCommand = "4";
- const string ExitCommand = "5";
- DataBase dataBase = new DataBase();
- string userInput;
- bool isWorking = true;
- while (isWorking)
- {
- Console.Clear();
- Console.WriteLine($"Выберите действие:\n{AddPlayerCommand})Добавить игрока.\n{BanPlayerCommand})Забанить игрока.\n{UnbanPlayerCommand})Разбанить игрока.\n{RemovePlayerCommand})Удалить игрока.\n{ExitCommand})Выход из программы.");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case AddPlayerCommand:
- dataBase.AddPlayer();
- break;
- case BanPlayerCommand:
- dataBase.BanPlayer();
- break;
- case UnbanPlayerCommand:
- dataBase.UnbanPlayer();
- break;
- case RemovePlayerCommand:
- dataBase.DeletePlayer();
- break;
- case ExitCommand:
- isWorking = false;
- break;
- }
- }
- }
- }
- class Player
- {
- public Player(int number, string nickname, int lvl, bool isBanned)
- {
- Number = number;
- Nickname = nickname;
- Lvl = lvl;
- IsBanned = isBanned;
- }
- public int Number { get; private set; }
- public string Nickname { get; private set; }
- public int Lvl { get; private set; }
- public bool IsBanned;
- }
- class DataBase
- {
- private List<Player> _players = new List<Player>();
- private int _universalNumber = 1000;
- public void ShowTablePlayers()
- {
- for (int i = 0; i < _players.Count; i++)
- {
- if (_players[i].IsBanned == true)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine($"Уникальный номер:{_players[i].Number}|Никнейм:{_players[i].Nickname}|LVL:{_players[i].Lvl}");
- Console.ForegroundColor = ConsoleColor.White;
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine($"Уникальный номер:{_players[i].Number}|Никнейм:{_players[i].Nickname}|LVL:{_players[i].Lvl}");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- }
- public void DeletePlayer()
- {
- int userInput;
- Console.WriteLine("Игрока под каким уникальным номером вы хотите удалить?");
- ShowTablePlayers();
- userInput = Convert.ToInt32(Console.ReadLine());
- _players.RemoveAt(userInput - 1000);
- }
- public void UnbanPlayer()
- {
- int userInput;
- Console.WriteLine("Игрока под каким уникальным номером вы хотите разбанить?");
- ShowTablePlayers();
- userInput = Convert.ToInt32(Console.ReadLine());
- _players[userInput - 1000].IsBanned = true;
- Console.ReadKey();
- }
- public void BanPlayer()
- {
- int userInput;
- Console.WriteLine("Игрока под каким уникальным номером вы хотите забанить?");
- ShowTablePlayers();
- userInput = Convert.ToInt32(Console.ReadLine());
- _players[userInput - 1000].IsBanned = false;
- Console.ReadKey();
- }
- public void AddPlayer()
- {
- string userInputName;
- int userInputLvl;
- Console.WriteLine("Введите ник игрока и его LVL");
- userInputName = Console.ReadLine();
- userInputLvl = Convert.ToInt32(Console.ReadLine());
- _players.Add(new Player(_universalNumber, userInputName, userInputLvl, true));
- _universalNumber++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement