Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _5._2
- {
- class Program
- {
- static void Main(string[] args)
- {
- PlayersList playersList = new PlayersList();
- playersList.AddPlayer(new Player("Rekc", 90), false);
- playersList.AddPlayer(new Player("Rekt", 70), true);
- playersList.print();
- playersList.BanPlayers(0);
- playersList.UnBanPlayers(1);
- playersList.print();
- playersList.RemovePlayer(0);
- playersList.print();
- }
- }
- public class Player
- {
- public string Name;
- public int Level;
- public Player (string name, int level)
- {
- Name = name;
- Level = level;
- }
- }
- class PlayersList
- {
- public List<DataBase> players = new List<DataBase>();
- public int countPlayers = 0;
- public void print()
- {
- for(int i = 0; i < players.Count; i++)
- {
- Console.WriteLine("Никнейм - " + players[i].Player.Name +
- "\nУровень - " + players[i].Player.Level +
- "\nДоступность - " + players[i].IsBun);
- Console.WriteLine();
- }
- }
- public void AddPlayer(Player player, bool isBun)
- {
- DataBase dataBase = new DataBase(player, countPlayers++, isBun);
- players.Add(dataBase);
- }
- public void RemovePlayer(int id)
- {
- for (int i = 0; i < players.Count; i++)
- {
- if (players[i].Id == id)
- {
- players.RemoveAt(i);
- }
- }
- }
- public void BanPlayers(int id)
- {
- searchIdForBun(id, true);
- }
- public void UnBanPlayers(int id)
- {
- searchIdForBun(id, false);
- }
- public void searchIdForBun(int id, bool isBun)
- {
- for (int i = 0; i < players.Count; i++)
- {
- if (players[i].Id == id)
- {
- players[i].IsBun = isBun;
- }
- }
- }
- }
- public class DataBase {
- public Player Player;
- public int Id;
- public bool IsBun;
- public DataBase(Player player, int id, bool isBun)
- {
- Player = player;
- Id = id;
- IsBun = isBun;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement