Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HW5._2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Players[] players = { new Players(1, "Aleks", 1, false) };
- int UserChoicePlayer, UserChoiceActionsPlayer,UserChoice,Exit;
- do
- {
- for (int i = 0; i < players.Length; i++)
- {
- players[i].ShowPlayer();
- Console.WriteLine();
- }
- Console.WriteLine("Хотите добавит игрока или изменить существующего?\n1)Добваить\n2)Изменить");
- UserChoice = Convert.ToInt32(Console.ReadLine());
- if (UserChoice == 1)
- {
- players[1].AddPlayer();// как тут исправить ?
- }
- else
- {
- Console.WriteLine("Выберите игрока по номеру");
- UserChoicePlayer = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine(players[UserChoicePlayer - 1]);
- Console.WriteLine("Выберите действие с игрком:\n1) Изменить ник\n2)Изменить уровень\nЗабанить(разбанить) игрока");
- UserChoiceActionsPlayer = Convert.ToInt32(Console.ReadLine());
- players[UserChoicePlayer - 1].ActionWithPlayer(UserChoiceActionsPlayer, UserChoicePlayer, ref players);
- }
- Console.WriteLine("Выйти?\n1) Да\n2)Нет");
- Exit = Convert.ToInt32(Console.ReadLine());
- } while (Exit == 1);
- }
- }
- class Players
- {
- string Name;
- int Number, Level;
- private bool _ban;
- public Players(int number,string name,int level,bool ban)
- {
- Name = name;
- Number = number;
- Level = level;
- _ban = ban;
- }
- public void ShowPlayer()
- {
- Console.WriteLine($"Number: {Number} Name: {Name} Level: {Level} Ban:{_ban} ");
- }
- public void ActionWithPlayer(int UserChoiceActionPlayer,int UserChoicePlayer,ref Players[] players)
- {
- switch (UserChoiceActionPlayer)
- {
- case (1):
- Console.Write("Введите новое имя: ");
- Name = Console.ReadLine();
- Console.WriteLine($"Новое имя {Name}");
- break;
- case (2):
- Console.Write("Введите новый уровень:");
- Level =Convert.ToInt32(Console.ReadLine());
- Console.WriteLine($"Новый уровень {Level}");
- break;
- case (3):
- if (_ban==false)
- {
- Console.WriteLine("Бан дан");
- _ban = true;
- }
- else
- {
- Console.WriteLine("Бан снят");
- _ban = false;
- }
- break;
- }
- }
- public void AddPlayer()
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement