Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Task54._2
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Database database = new Database();
- database.Work();
- }
- }
- class Database
- {
- private List<Player> _players;
- private int _maxCountTopPlayers;
- public Database()
- {
- _players = new List<Player>();
- _maxCountTopPlayers = 3;
- _players.Add(new Player("Doctor", 18, 826));
- _players.Add(new Player("xFaZe", 58, 252));
- _players.Add(new Player("Teнь", 75, 824));
- _players.Add(new Player("Безумный_автобус", 50, 740));
- _players.Add(new Player("Magic", 93, 172));
- _players.Add(new Player("G.R.I.Z.Z.L.I", 44, 293));
- _players.Add(new Player("Летучий Олень", 15, 326));
- _players.Add(new Player("Aim41K", 88, 509));
- _players.Add(new Player("D_O_M_I_N_A_T_O_R", 35, 541));
- _players.Add(new Player("Mr. Zadrot", 12, 539));
- _players.Add(new Player("IceStorm", 24, 967));
- }
- public void Work()
- {
- string listPlayers =
- "Список всех игроков: ";
- string listTopLevelPlayers =
- "Список топ игроков по уровню: ";
- string listTopPowerPlayers =
- "Список топ игроков по силе: ";
- Console.WriteLine(listPlayers);
- Show(_players);
- Console.WriteLine();
- Console.WriteLine(listTopLevelPlayers);
- ShowTopPlayerLevel();
- Console.WriteLine();
- Console.WriteLine(listTopPowerPlayers);
- ShowTopPlayerPower();
- Console.WriteLine();
- }
- private void ShowTopPlayerLevel()
- {
- List<Player> topPlayer = new List<Player>();
- topPlayer = _players.OrderByDescending(player => player.Level).Take(_maxCountTopPlayers).ToList();
- Show(topPlayer);
- }
- private void ShowTopPlayerPower()
- {
- List<Player> topPlayer = new List<Player>();
- topPlayer = _players.OrderByDescending(player => player.Power).Take(_maxCountTopPlayers).ToList();
- Show(topPlayer);
- }
- private void Show(List<Player> players)
- {
- foreach (var player in players)
- {
- player.Show();
- }
- }
- }
- class Player
- {
- public string Nickname { get; private set; }
- public int Level { get; private set; }
- public int Power { get; private set; }
- public Player(string nickname, int level, int power)
- {
- Nickname = nickname;
- Level = level;
- Power = power;
- }
- public void Show()
- {
- Console.WriteLine(
- $"Карточка игрока:\n" +
- $"Никнейм : {Nickname}\n" +
- $"Уровень : {Level}\n" +
- $"Сила : {Power}\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement