Created
August 9, 2023 23:16
-
-
Save ShamilAitov/6903121bc2e5c5d822e039997e540069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace LINQ7Задание | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
MilitaryProgram militaryProgram = new MilitaryProgram(); | |
militaryProgram.Play(); | |
} | |
} | |
class MilitaryProgram | |
{ | |
private List<Soldier> _soldiers = new List<Soldier>(); | |
public MilitaryProgram() | |
{ | |
FillSoldiers(); | |
} | |
public void Play() | |
{ | |
var dossier = _soldiers.Select(Soldier => new { Name = Soldier.Name, Title = Soldier.Title }); | |
foreach (var soldier in dossier) | |
{ | |
Console.WriteLine($"{soldier.Name} - {soldier.Title}"); | |
} | |
} | |
private void FillSoldiers() | |
{ | |
_soldiers.Add(new Soldier("Аберфорт", "Автомат", "Лейтинант", 12)); | |
_soldiers.Add(new Soldier("Адриан", "Пистолет", "Майор", 66)); | |
_soldiers.Add(new Soldier("Арчибальд", "Пулемет", "Старлей", 18)); | |
_soldiers.Add(new Soldier("Бруно", "Базука", "Капитан", 36)); | |
_soldiers.Add(new Soldier("Генри", "Пулемет", "Полковник", 110)); | |
_soldiers.Add(new Soldier("Киллиан", "Автомат", "Генерал", 180)); | |
} | |
} | |
class Soldier | |
{ | |
public Soldier(string name, string armament, string title, int serviceLife) | |
{ | |
Name = name; | |
Armament = armament; | |
Title = title; | |
ServiceLife = serviceLife; | |
} | |
public string Name { get; private set; } | |
public string Armament { get; private set; } | |
public string Title { get; private set; } | |
public int ServiceLife { get; private set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment