using System;
using System.Collections.Generic;
using System.Linq;
class Product
{
public string Name { get; set; }
public decimal Price { get; set; }
public int Quantity { get; set; }
}
class Program
{
static void Main()
{
List<Product> products = new List<Product>
{
new Product { Name = "Ноутбук", Price = 65000, Quantity = 3 },
new Product { Name = "Мышь", Price = 1500, Quantity = 10 },
new Product { Name = "Клавиатура", Price = 4000, Quantity = 5 },
new Product { Name = "Монитор", Price = 20000, Quantity = 4 },
new Product { Name = "Наушники", Price = 3000, Quantity = 8 }
};
while (true)
{
Console.WriteLine("\n=== МИНИ-МАГАЗИН ===");
Console.WriteLine("1. Показать товары");
Console.WriteLine("2. Найти товар");
Console.WriteLine("3. Сортировать по цене");
Console.WriteLine("4. Посчитать стоимость склада");
Console.WriteLine("0. Выход");
Console.Write("Выберите действие: ");
string choice = Console.ReadLine();
if (choice == "0")
break;
switch (choice)
{
case "1":
foreach (Product p in products)
Console.WriteLine($"{p.Name}: {p.Price} руб., остаток: {p.Quantity}");
break;
case "2":
Console.Write("Введите название: ");
string name = Console.ReadLine();
var found = products.Where(p =>
p.Name.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0);
foreach (Product p in found)
Console.WriteLine($"{p.Name} — {p.Price} руб.");
break;
case "3":
foreach (Product p in products.OrderBy(p => p.Price))
Console.WriteLine($"{p.Name} — {p.Price} руб.");
break;
case "4":
decimal total = products.Sum(p => p.Price * p.Quantity);
Console.WriteLine($"Стоимость склада: {total} руб.");
break;
default:
Console.WriteLine("Неизвестная команда!");
break;
}
}
}
}