Advertisement
lekss361

Untitled

Oct 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HW5._2
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. Players[] players = { new Players(1, "Aleks", 1, false) };
  10. int UserChoicePlayer, UserChoiceActionsPlayer,UserChoice,Exit;
  11. do
  12. {
  13. for (int i = 0; i < players.Length; i++)
  14. {
  15. players[i].ShowPlayer();
  16. Console.WriteLine();
  17. }
  18.  
  19. Console.WriteLine("Хотите добавит игрока или изменить существующего?\n1)Добваить\n2)Изменить");
  20. UserChoice = Convert.ToInt32(Console.ReadLine());
  21.  
  22. if (UserChoice == 1)
  23. {
  24. players[1].AddPlayer();// как тут исправить ?
  25. }
  26. else
  27. {
  28. Console.WriteLine("Выберите игрока по номеру");
  29. UserChoicePlayer = Convert.ToInt32(Console.ReadLine());
  30. Console.WriteLine(players[UserChoicePlayer - 1]);
  31. Console.WriteLine("Выберите действие с игрком:\n1) Изменить ник\n2)Изменить уровень\nЗабанить(разбанить) игрока");
  32. UserChoiceActionsPlayer = Convert.ToInt32(Console.ReadLine());
  33. players[UserChoicePlayer - 1].ActionWithPlayer(UserChoiceActionsPlayer, UserChoicePlayer, ref players);
  34. }
  35.  
  36. Console.WriteLine("Выйти?\n1) Да\n2)Нет");
  37. Exit = Convert.ToInt32(Console.ReadLine());
  38. } while (Exit == 1);
  39. }
  40. }
  41. class Players
  42. {
  43. string Name;
  44. int Number, Level;
  45. private bool _ban;
  46. public Players(int number,string name,int level,bool ban)
  47. {
  48. Name = name;
  49. Number = number;
  50. Level = level;
  51. _ban = ban;
  52.  
  53. }
  54.  
  55. public void ShowPlayer()
  56. {
  57. Console.WriteLine($"Number: {Number} Name: {Name} Level: {Level} Ban:{_ban} ");
  58. }
  59.  
  60. public void ActionWithPlayer(int UserChoiceActionPlayer,int UserChoicePlayer,ref Players[] players)
  61. {
  62. switch (UserChoiceActionPlayer)
  63. {
  64. case (1):
  65. Console.Write("Введите новое имя: ");
  66. Name = Console.ReadLine();
  67. Console.WriteLine($"Новое имя {Name}");
  68. break;
  69. case (2):
  70. Console.Write("Введите новый уровень:");
  71. Level =Convert.ToInt32(Console.ReadLine());
  72. Console.WriteLine($"Новый уровень {Level}");
  73. break;
  74. case (3):
  75. if (_ban==false)
  76. {
  77. Console.WriteLine("Бан дан");
  78. _ban = true;
  79. }
  80. else
  81. {
  82. Console.WriteLine("Бан снят");
  83. _ban = false;
  84. }
  85. break;
  86. }
  87.  
  88. }
  89.  
  90. public void AddPlayer()
  91. {
  92.  
  93. }
  94.  
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement