Zlobin2021

Shop

Apr 6th, 2022 (edited)
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace shop
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Cashbox cashbox = new Cashbox();
  11.  
  12.             while (true)
  13.             {
  14.  
  15.                 Console.ReadKey();
  16.             }
  17.         }
  18.     }
  19.  
  20.     class Cashbox
  21.     {
  22.         Queue<Client> clients = new Queue<Client>();
  23.  
  24.         public void AddClient()
  25.         {
  26.             clients.Enqueue();
  27.         }
  28.  
  29.         public void ShowInfo()
  30.         {
  31.             for (int i = 0; i < clients.Count; i++)
  32.             {
  33.                 Console.WriteLine(clients.Peek());
  34.             }
  35.         }
  36.     }
  37.  
  38.     class Client
  39.     {
  40.         public int Money { get; private set; }
  41.  
  42.         Basket basket = new Basket();
  43.         Random random = new Random();
  44.  
  45.         public Client()
  46.         {
  47.             int money = random.Next(1000, 15000);
  48.  
  49.             Money = money;
  50.             basket = new Basket();
  51.         }
  52.     }
  53.  
  54.     class Basket
  55.     {
  56.         List<Product> basket = new List<Product>();
  57.  
  58.         public Basket()
  59.         {
  60.             PutProducts();
  61.         }
  62.  
  63.         private void PutProducts()
  64.         {
  65.             Random random = new Random();
  66.             int products = random.Next(0, 10);
  67.  
  68.             for (int i = 0; i < products; i++)
  69.             {
  70.                 basket.Add(new Product());
  71.             }
  72.         }
  73.     }
  74.  
  75.     class Product
  76.     {
  77.         public int Price { get; private set; }
  78.  
  79.         Random random = new Random();
  80.         public Product()
  81.         {
  82.             int price = random.Next(1, 1000);
  83.             Price = price;
  84.         }
  85.     }
  86. }
Add Comment
Please, Sign In to add comment