Advertisement
VodVas

Untitled

Nov 22nd, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. using System.Diagnostics;
  2. using System.Xml.Linq;
  3.  
  4. namespace Супермаркет
  5. {
  6. internal class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Supermarket supermarket = new Supermarket();
  11.  
  12. supermarket.FillBasket();
  13. }
  14. }
  15.  
  16. class Supermarket
  17. {
  18. private List<Product> _products = new List<Product>();
  19.  
  20.  
  21. private Random _random = new Random();
  22.  
  23. public Supermarket()
  24. {
  25. _products.Add(new Product(0, "Пакет", 10));
  26. _products.Add(new Product(1, "Бананы", 85));
  27. _products.Add(new Product(2, "Молоко", 65));
  28. _products.Add(new Product(3, "Пиво", 50));
  29. _products.Add(new Product(4, "Курица", 320));
  30. _products.Add(new Product(5, "Сосиски", 125));
  31. _products.Add(new Product(6, "Кола", 75));
  32. }
  33.  
  34. public List<Product> FillBasket()
  35. {
  36. int buyersWish = _random.Next(1, 10);
  37.  
  38. List<Product> _buyersBasket = new List<Product>(buyersWish);
  39.  
  40. for (int i = 0; i < buyersWish; i++)
  41. {
  42. int randomProduct = _random.Next(0, _products.Count);
  43.  
  44. _buyersBasket.Add(_products[randomProduct]);
  45.  
  46. Console.WriteLine($"ID: {_buyersBasket[i].Id} Название: {_buyersBasket[i].Title} Цена: {_buyersBasket[i].Price} Руб.");
  47.  
  48.  
  49. }
  50.  
  51. return _buyersBasket;
  52. }
  53.  
  54. public void ShowProduct()
  55. {
  56. for (int i = 0; i < _products.Count; i++)
  57. {
  58. Console.WriteLine($"ID: {_products[i].Id} Название: {_products[i].Title} Цена: {_products[i].Price} Руб.");
  59. }
  60. }
  61.  
  62. }
  63. class Client
  64. {
  65.  
  66. private List<Product> _buyersProducts = new List<Product>();
  67.  
  68. private int _money;
  69.  
  70. private Random _random = new Random();
  71.  
  72. public void FillBasket()
  73. {
  74. int _randomProductsQuantity = _random.Next(0, 5);
  75.  
  76. for (int i = 0; i < _randomProductsQuantity; i++)
  77. {
  78. //_buyersProducts.Add();
  79.  
  80.  
  81. }
  82. }
  83. }
  84.  
  85. class Product
  86. {
  87. public Product(int id, string name, int price)
  88. {
  89. Id = id;
  90. Title = name;
  91. Price = price;
  92. }
  93.  
  94. public int Id { get; private set; }
  95. public string Title { get; private set; }
  96. public int Price { get; private set; }
  97.  
  98. public void ShowProduct()
  99. {
  100. Console.WriteLine($"ID: {Id} Название: {Title} Цена: {Price}$");
  101. }
  102. }
  103.  
  104.  
  105.  
  106. class Utility
  107. {
  108. public static int ReturnValidateInputNumber()
  109. {
  110. int number;
  111.  
  112. while (int.TryParse(Console.ReadLine(), out number) == false)
  113. {
  114. Console.WriteLine("Введено не число, попробуйте еще раз: ");
  115. }
  116.  
  117. return number;
  118. }
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement