Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace top
- {
- class Program
- {
- static void Main(string[] args)
- {
- int playersInTop = 3;
- List<Player> players = new List<Player>()
- {
- new Player("Gamer3000", 80, 200),
- new Player("Jecki", 42, 100),
- new Player("Anton", 40, 125),
- new Player("Vasyan99", 5, 15),
- new Player("Ignat", 15, 33),
- new Player("Belyj", 31, 97),
- new Player("Freeman", 22, 46),
- new Player("Ivan", 21, 44),
- new Player("Leo", 66, 99),
- new Player("Ark", 65, 152),
- new Player("Regina", 79, 124),
- new Player("Lupin", 25, 71),
- };
- var topLevel = players.OrderByDescending(player => player.Level).Take(playersInTop);
- Console.WriteLine("Топ игроков по уровню:");
- ShowPlayers(topLevel);
- var topStrength = players.OrderByDescending(player => player.Strength).Take(playersInTop);
- Console.WriteLine("\nТоп игроков по силе:");
- ShowPlayers(topStrength);
- }
- static private void ShowPlayers(IEnumerable<Player> players)
- {
- foreach (var player in players)
- player.ShowInfo();
- }
- }
- class Player
- {
- public Player(string nick, int level, int strength)
- {
- Nick = nick;
- Level = level;
- Strength = strength;
- }
- public string Nick { get; private set; }
- public int Level { get; private set; }
- public int Strength { get; private set; }
- public void ShowInfo()
- {
- Console.WriteLine($"{Nick} уровень:{Level} сила:{Strength}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement