Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Diagnostics;
- using System.Xml.Linq;
- namespace Супермаркет
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Supermarket supermarket = new Supermarket();
- supermarket.FillBasket();
- }
- }
- class Supermarket
- {
- private List<Product> _products = new List<Product>();
- private Random _random = new Random();
- public Supermarket()
- {
- _products.Add(new Product(0, "Пакет", 10));
- _products.Add(new Product(1, "Бананы", 85));
- _products.Add(new Product(2, "Молоко", 65));
- _products.Add(new Product(3, "Пиво", 50));
- _products.Add(new Product(4, "Курица", 320));
- _products.Add(new Product(5, "Сосиски", 125));
- _products.Add(new Product(6, "Кола", 75));
- }
- public List<Product> FillBasket()
- {
- int buyersWish = _random.Next(1, 10);
- List<Product> _buyersBasket = new List<Product>(buyersWish);
- for (int i = 0; i < buyersWish; i++)
- {
- int randomProduct = _random.Next(0, _products.Count);
- _buyersBasket.Add(_products[randomProduct]);
- Console.WriteLine($"ID: {_buyersBasket[i].Id} Название: {_buyersBasket[i].Title} Цена: {_buyersBasket[i].Price} Руб.");
- }
- return _buyersBasket;
- }
- public void ShowProduct()
- {
- for (int i = 0; i < _products.Count; i++)
- {
- Console.WriteLine($"ID: {_products[i].Id} Название: {_products[i].Title} Цена: {_products[i].Price} Руб.");
- }
- }
- }
- class Client
- {
- private List<Product> _buyersProducts = new List<Product>();
- private int _money;
- private Random _random = new Random();
- public void FillBasket()
- {
- int _randomProductsQuantity = _random.Next(0, 5);
- for (int i = 0; i < _randomProductsQuantity; i++)
- {
- //_buyersProducts.Add();
- }
- }
- }
- class Product
- {
- public Product(int id, string name, int price)
- {
- Id = id;
- Title = name;
- Price = price;
- }
- public int Id { get; private set; }
- public string Title { get; private set; }
- public int Price { get; private set; }
- public void ShowProduct()
- {
- Console.WriteLine($"ID: {Id} Название: {Title} Цена: {Price}$");
- }
- }
- class Utility
- {
- public static int ReturnValidateInputNumber()
- {
- int number;
- while (int.TryParse(Console.ReadLine(), out number) == false)
- {
- Console.WriteLine("Введено не число, попробуйте еще раз: ");
- }
- return number;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement