123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- class Goods
- {
- public string Name { get;set; }
- public int Price { get; set; }
- public int Amount { get; set; }
- public string category { get; set; }
- public Goods(string name, int price, int amount, string category)
- {
- Name = name;
- Price = price;
- Amount = amount;
- this.category = category;
- }
- }
- class Category
- {
- public string Title { get; set; }
- public Category(string title)
- {
- Title = title;
- }
- }
- class Seller
- {
- public string Name { get; set; }
- public int Reviews { get; set; }
- public List<Goods> GoodsList;
- public Seller(string name, int reviews, List<Goods> goodsList)
- {
- Name = name;
- Reviews = reviews;
- GoodsList = goodsList;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- List<Category> categories = new List<Category>()
- {
- new Category("Brawl"),
- new Category("Roblox"),
- new Category("Mine"),
- new Category("Pubg")
- };
- List<Goods> goods = new List<Goods>()
- {
- new Goods("Gems", 100, 37,categories[0].Title),
- new Goods("Robux", 200, 5,categories[1].Title),
- new Goods("Robux", 300, 25,categories[1].Title),
- new Goods("Robux", 100, 50,categories[1].Title),
- new Goods("Acc", 2000, 3,categories[2].Title)
- };
- List<Seller> sellers = new List<Seller>()
- {
- new Seller("TopSell", 111, new List<Goods>() {goods[0], goods[2]}),
- new Seller("GameDealer", 222, new List<Goods>() {goods[1]}),
- new Seller("CANE2280", 3178, new List<Goods>() {goods[3]}),
- new Seller("SashaB116", 666, new List<Goods>() {goods[4]})
-
- };
- List<Tuple<string, string, int, int, string, int>> data =
- new List<Tuple<string, string, int, int, string, int>>();
- foreach (var sel in sellers)
- {
- foreach (var selGod in sel.GoodsList)
- {
- data.Add(new Tuple<string, string, int, int, string, int>(selGod.category, selGod.Name, selGod.Amount, selGod.Price, sel.Name, sel.Reviews));
- }
- }
- while (true)
- {
- Console.Write("Выберите метод сортировки:\n1. По убыванию\n2. По возрастанию\n>>> ");
- int ch0 = Convert.ToInt32(Console.ReadLine());
- Console.Write(
- "Выберите метод сортировки:\n1. По категории\n2. По количеству\n3. По цене\n4. По отзывам\n>>> ");
- int ch = Convert.ToInt32(Console.ReadLine());
- IOrderedEnumerable<Tuple<string, string, int, int, string, int>> filData = null;
- switch (ch)
- {
- case 1:
- if (ch0 == 2) filData = data.OrderBy(d => d.Item1);
- else filData = data.OrderByDescending(d => d.Item1);
- break;
- case 2:
- if (ch0 == 2) filData = data.OrderBy(d => d.Item3);
- else filData = data.OrderByDescending(d => d.Item3);
- break;
- case 3:
- if (ch0 == 2) filData = data.OrderBy(d => d.Item4);
- else filData = data.OrderByDescending(d => d.Item4);
- break;
- case 4:
- if (ch0 == 2) filData = data.OrderBy(d => d.Item6);
- else filData = data.OrderByDescending(d => d.Item6);
- break;
- }
- Console.WriteLine("Категор Предмет Кол-во Цена Продавец Отзывы");
- foreach (var i in filData)
- {
- Console.WriteLine($"{i.Item1}\t {i.Item2}\t {i.Item3}\t {i.Item4}\t {i.Item5}\t {i.Item6}");
- }
- }
- }
- }
|