Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ShopQueue
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int shopBalance = 0;
- Queue<int> purchase = new Queue<int>();
- FillQueue(purchase);
- shopBalance = SellProduct(purchase, shopBalance);
- ShowShopBalance(shopBalance);
- }
- static void ShowShopBalance(int shopBalance)
- {
- Console.WriteLine($"Средств на балансе магазина - {shopBalance}");
- }
- static void FillQueue(Queue<int> queue)
- {
- Random random = new Random();
- int maxNumbersPurchase = 20;
- int minNumbersPurchase = 1;
- int maxCostPurchase = 2000;
- int minCostPurchase = 1;
- int purchaseNumbers = random.Next(minNumbersPurchase, maxNumbersPurchase + 1);
- for (int i = 0; i < purchaseNumbers; i++)
- {
- queue.Enqueue(random.Next(minCostPurchase, maxCostPurchase));
- }
- }
- static int SellProduct(Queue<int> queue, int shopBalance)
- {
- while(queue.Count > 0)
- {
- ShowQueueInfo(queue);
- Console.WriteLine($"На балансе {shopBalance}.");
- shopBalance += queue.Dequeue();
- Console.ReadKey();
- Console.Clear();
- }
- return shopBalance;
- }
- static void ShowQueueInfo(Queue<int> queue)
- {
- Console.WriteLine("Стоимость каждой покупки в очереди");
- foreach (int pricePurchse in queue)
- {
- Console.Write(pricePurchse + "||");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment