Advertisement
loleckek228

5.2

Sep 19th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _5._2
  5. {
  6.    
  7.  
  8.     class Program
  9.     {
  10.        
  11.  
  12.         static void Main(string[] args)
  13.         {
  14.             PlayersList playersList = new PlayersList();
  15.             playersList.AddPlayer(new Player("Rekc", 90), false);
  16.             playersList.AddPlayer(new Player("Rekt", 70), true);
  17.             playersList.print();
  18.             playersList.BanPlayers(0);
  19.             playersList.UnBanPlayers(1);
  20.             playersList.print();
  21.             playersList.RemovePlayer(0);
  22.             playersList.print();
  23.         }
  24.     }
  25.  
  26.     public class Player
  27.     {
  28.         public string Name;
  29.         public int Level;
  30.        
  31.  
  32.         public Player (string name, int level)
  33.         {
  34.             Name = name;
  35.             Level = level;
  36.         }
  37.     }
  38.  
  39.     class PlayersList
  40.     {
  41.         public List<DataBase> players = new List<DataBase>();
  42.         public int countPlayers = 0;
  43.  
  44.         public void print()
  45.         {
  46.             for(int i = 0; i < players.Count; i++)
  47.             {
  48.                 Console.WriteLine("Никнейм - " + players[i].Player.Name +
  49.  
  50.                     "\nУровень - " + players[i].Player.Level +
  51.                     "\nДоступность - " + players[i].IsBun);
  52.                 Console.WriteLine();
  53.             }
  54.         }
  55.  
  56.         public void AddPlayer(Player player, bool isBun)
  57.         {
  58.             DataBase dataBase = new DataBase(player, countPlayers++, isBun);
  59.             players.Add(dataBase);          
  60.         }
  61.  
  62.         public void RemovePlayer(int id)
  63.         {
  64.             for (int i = 0; i < players.Count; i++)
  65.             {
  66.                 if (players[i].Id == id)
  67.                 {
  68.                     players.RemoveAt(i);
  69.                 }
  70.             }
  71.         }
  72.        
  73.         public void BanPlayers(int id)
  74.         {
  75.             searchIdForBun(id, true);
  76.         }
  77.  
  78.         public void UnBanPlayers(int id)
  79.         {
  80.  
  81.             searchIdForBun(id, false);
  82.         }
  83.  
  84.         public void searchIdForBun(int id, bool isBun)
  85.         {
  86.             for (int i = 0; i < players.Count; i++)
  87.             {
  88.                 if (players[i].Id == id)
  89.                 {
  90.                     players[i].IsBun = isBun;
  91.                 }
  92.             }
  93.         }
  94.     }
  95.  
  96.     public class DataBase {
  97.  
  98.         public Player Player;
  99.         public int Id;
  100.         public bool IsBun;
  101.  
  102.         public DataBase(Player player, int id, bool isBun)
  103.         {
  104.             Player = player;
  105.             Id = id;
  106.             IsBun = isBun;
  107.         }
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement