Files
oop/labs/lab9/LearningCenter/Program.cs
2025-09-30 08:21:09 +03:00

31 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
var people = new List<Person>
{
new Administrator("Иванова", new DateTime(1985, 3, 12), "Лаборатория сетей", 8, 900m),
new Student("Петров", new DateTime(2005, 11, 2), "ФКТИ", 2),
new Teacher("Сидоров", new DateTime(1979, 6, 25), "ФКТИ", "Доцент", 12, 1400m),
new Manager("Кузнецова", new DateTime(1990, 1, 5), "ФКТИ", "Менеджер проектов", 6, 1100m),
new Student("Орлова", new DateTime(2003, 4, 17), "ФПМИ", 4)
};
foreach (var p in people) p.Show();
Console.WriteLine();
int from = 20, to = 40;
var inRange = people.Where(p => p.Age() >= from && p.Age() <= to);
foreach (var p in inRange) p.Show();
Console.WriteLine();
foreach (var e in people.OfType<IEmployee>())
Console.WriteLine("{0}: {1}, подразделение: {2}, оклад: {3:F2}", e.GetType().Name, e.Position, e.Department, e.GetMonthlyPay());
}
}