Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Home_Work
- {
- class Program
- {
- static void Main(string[] args)
- {
- Queue<int> clients = new Queue<int>();
- FillQueue(clients);
- Work(clients);
- }
- static void Work(Queue<int> clients)
- {
- int cash = 0;
- while (clients.Count > 0)
- {
- ServeClient(clients, ref cash);
- Console.WriteLine("Нажмите любую клавишу, что бы обслужить следующого клиента.");
- Console.ReadKey();
- Console.Clear();
- }
- Console.WriteLine("Клиенты закончились.\n" +
- $"Вы заработали {cash}.\n");
- Console.ReadKey();
- }
- static void ServeClient(Queue<int> clients, ref int cash)
- {
- cash += clients.Peek();
- Console.WriteLine($"В очереди {clients.Count} человек.\n" +
- $"Клиент заплатил за покупки {clients.Dequeue()}.\n" +
- $"Всего в кассе {cash}.\n");
- }
- static void FillQueue(Queue<int> clients)
- {
- Random random = new Random();
- int numberOfClients = 10;
- for (int i = 0; i < numberOfClients; i++)
- {
- clients.Enqueue(random.Next(100, 1000));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment