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 Task56
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Archive archive = new Archive();
- archive.ShowNamesRanks();
- }
- }
- class Archive
- {
- private List<Soldier> _soldiers;
- public Archive()
- {
- _soldiers = new List<Soldier>();
- _soldiers.Add(new Soldier("Владимир", "Ак-76","Рядовой",2));
- _soldiers.Add(new Soldier("Игорь", "Автомат Фёдорова", "Младший лейтенант",3));
- _soldiers.Add(new Soldier("Максим", "СГК «Канарейка»", "Капитан",11));
- _soldiers.Add(new Soldier("Константин", "ОЦ-14 «Гроза»", "Полковник",15));
- _soldiers.Add(new Soldier("Алексей", "Сапёрная лопатка", "Ефрейтор",1));
- }
- public void ShowNamesRanks()
- {
- var sortSoldiers = from Soldier soldier in _soldiers
- select new
- {
- name = soldier.Name,
- title = soldier.Title
- };
- foreach (var soldier in sortSoldiers)
- {
- Console.WriteLine(
- $"Карточка солдата:\n" +
- $"Имя: {soldier.name}\n" +
- $"Звание: {soldier.title}\n");
- }
- }
- }
- class Soldier
- {
- public string Name { get; private set; }
- public string Armament { get; private set; }
- public string Title { get; private set; }
- public int LifeTime { get; private set; }
- public Soldier(string name, string armament, string title, int lifeTime)
- {
- Name = name;
- Armament = armament;
- Title = title;
- LifeTime = lifeTime;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement