Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- namespace Топ_игроков_сервера
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Server server = new Server();
- server.Work();
- }
- }
- class Server
- {
- private List<Player> _players = new List<Player>();
- private int _quantityTopPlayers = 3;
- public Server()
- {
- _players.Add(new Player("electroNic", 93, 2200));
- _players.Add(new Player("device", 88, 2430));
- _players.Add(new Player("Magisk", 99, 2300));
- _players.Add(new Player("dupreeh", 70, 2500));
- _players.Add(new Player("Xyp9x", 63, 2450));
- _players.Add(new Player("gla1ve", 94, 2400));
- _players.Add(new Player("FalleN", 87, 2100));
- _players.Add(new Player("karrigan", 85, 2170));
- _players.Add(new Player("s1mple", 77, 2320));
- _players.Add(new Player("TACO", 90, 2150));
- }
- public void Work()
- {
- Console.WriteLine("Игроки на сервере:");
- ShowPlayersList(_players);
- Console.WriteLine($"\nТоп {_quantityTopPlayers} игроков по уровню:");
- ShowLevelTop();
- Console.WriteLine($"\nТоп {_quantityTopPlayers} игроков по силе:");
- ShowPowerTop();
- }
- private void ShowPowerTop()
- {
- List<Player> topPowerPlayers = new List<Player>();
- topPowerPlayers = _players.OrderByDescending(player => player.Power).Take(_quantityTopPlayers).ToList();
- ShowPlayersList(topPowerPlayers);
- }
- private void ShowLevelTop()
- {
- List<Player> topLevelPlayers = new List<Player>();
- topLevelPlayers = _players.OrderByDescending(player => player.Level).Take(_quantityTopPlayers).ToList();
- ShowPlayersList(topLevelPlayers);
- }
- private void ShowPlayersList(List<Player> players)
- {
- foreach (var player in players)
- {
- player.ShowDescription();
- }
- }
- }
- class Player
- {
- public Player(string name, int level, int power)
- {
- Name = name;
- Level = level;
- Power = power;
- }
- public string Name { get; private set; }
- public int Level { get; private set; }
- public int Power { get; private set; }
- public void ShowDescription()
- {
- Console.WriteLine($"Имя: {Name} Уровень: {Level} Power: {Power}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement