Program.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. class Goods
  2. {
  3. public string Name { get;set; }
  4. public int Price { get; set; }
  5. public int Amount { get; set; }
  6. public string category { get; set; }
  7. public Goods(string name, int price, int amount, string category)
  8. {
  9. Name = name;
  10. Price = price;
  11. Amount = amount;
  12. this.category = category;
  13. }
  14. }
  15. class Category
  16. {
  17. public string Title { get; set; }
  18. public Category(string title)
  19. {
  20. Title = title;
  21. }
  22. }
  23. class Seller
  24. {
  25. public string Name { get; set; }
  26. public int Reviews { get; set; }
  27. public List<Goods> GoodsList;
  28. public Seller(string name, int reviews, List<Goods> goodsList)
  29. {
  30. Name = name;
  31. Reviews = reviews;
  32. GoodsList = goodsList;
  33. }
  34. }
  35. class Program
  36. {
  37. static void Main(string[] args)
  38. {
  39. List<Category> categories = new List<Category>()
  40. {
  41. new Category("Brawl"),
  42. new Category("Roblox"),
  43. new Category("Mine"),
  44. new Category("Pubg")
  45. };
  46. List<Goods> goods = new List<Goods>()
  47. {
  48. new Goods("Gems", 100, 37,categories[0].Title),
  49. new Goods("Robux", 200, 5,categories[1].Title),
  50. new Goods("Robux", 300, 25,categories[1].Title),
  51. new Goods("Robux", 100, 50,categories[1].Title),
  52. new Goods("Acc", 2000, 3,categories[2].Title)
  53. };
  54. List<Seller> sellers = new List<Seller>()
  55. {
  56. new Seller("TopSell", 111, new List<Goods>() {goods[0], goods[2]}),
  57. new Seller("GameDealer", 222, new List<Goods>() {goods[1]}),
  58. new Seller("CANE2280", 3178, new List<Goods>() {goods[3]}),
  59. new Seller("SashaB116", 666, new List<Goods>() {goods[4]})
  60. };
  61. List<Tuple<string, string, int, int, string, int>> data =
  62. new List<Tuple<string, string, int, int, string, int>>();
  63. foreach (var sel in sellers)
  64. {
  65. foreach (var selGod in sel.GoodsList)
  66. {
  67. data.Add(new Tuple<string, string, int, int, string, int>(selGod.category, selGod.Name, selGod.Amount, selGod.Price, sel.Name, sel.Reviews));
  68. }
  69. }
  70. while (true)
  71. {
  72. Console.Write("Выберите метод сортировки:\n1. По убыванию\n2. По возрастанию\n>>> ");
  73. int ch0 = Convert.ToInt32(Console.ReadLine());
  74. Console.Write(
  75. "Выберите метод сортировки:\n1. По категории\n2. По количеству\n3. По цене\n4. По отзывам\n>>> ");
  76. int ch = Convert.ToInt32(Console.ReadLine());
  77. IOrderedEnumerable<Tuple<string, string, int, int, string, int>> filData = null;
  78. switch (ch)
  79. {
  80. case 1:
  81. if (ch0 == 2) filData = data.OrderBy(d => d.Item1);
  82. else filData = data.OrderByDescending(d => d.Item1);
  83. break;
  84. case 2:
  85. if (ch0 == 2) filData = data.OrderBy(d => d.Item3);
  86. else filData = data.OrderByDescending(d => d.Item3);
  87. break;
  88. case 3:
  89. if (ch0 == 2) filData = data.OrderBy(d => d.Item4);
  90. else filData = data.OrderByDescending(d => d.Item4);
  91. break;
  92. case 4:
  93. if (ch0 == 2) filData = data.OrderBy(d => d.Item6);
  94. else filData = data.OrderByDescending(d => d.Item6);
  95. break;
  96. }
  97. Console.WriteLine("Категор Предмет Кол-во Цена Продавец Отзывы");
  98. foreach (var i in filData)
  99. {
  100. Console.WriteLine($"{i.Item1}\t {i.Item2}\t {i.Item3}\t {i.Item4}\t {i.Item5}\t {i.Item6}");
  101. }
  102. }
  103. }
  104. }