Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.IO;
- using System.ComponentModel;
- namespace Lesson1
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Stew> stews = new List<Stew>()
- {
- new Stew("Свинина", 2012, 20),
- new Stew("Говядина", 2016, 25),
- new Stew("Килька", 2020, 15),
- new Stew("Свинина", 2003, 20),
- new Stew("Сгущенка", 2017, 2),
- new Stew("Свинина", 2006, 20),
- new Stew("Свинина", 1970, 20),
- new Stew("Говядина", 2015, 25),
- new Stew("Килька", 1997, 15),
- new Stew("Сгущенка", 2019, 2),
- };
- foreach (var stew in stews)
- {
- Console.WriteLine($"{stew.Name} - {stew.ProducrionYear} года хранится {stew.ExpirationYear} лет");
- }
- var expiredStew = stews.Where(stew => stew.ProducrionYear + stew.ExpirationYear <= DateTime.Now.Year);
- Console.WriteLine("\nПросрочены: ");
- foreach (var stew in expiredStew)
- {
- Console.WriteLine($"{stew.Name} - {stew.ProducrionYear} года хранится {stew.ExpirationYear} лет");
- }
- Console.ReadKey();
- }
- }
- class Stew
- {
- public string Name;
- public int ProducrionYear;
- public int ExpirationYear;
- public Stew(string name, int producrionDate, int expirationYear)
- {
- Name = name;
- ProducrionYear = producrionDate;
- ExpirationYear = expirationYear;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement