Advertisement
radidim

P06.Supermarket (C# Shell App Paste)

Jul 6th, 2020
1,468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.  
  10.     public static class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.             var queue = new Queue<string>();
  15.             while (true)
  16.             {
  17.                 var command = Console.ReadLine();
  18.                 if (command == "Paid")
  19.                 {
  20.                     while (queue.Any())
  21.                     {
  22.                         Console.WriteLine(queue.Dequeue());
  23.                     }
  24.                 }
  25.                 else if (command == "End")
  26.                 {
  27.                     Console.WriteLine($"{queue.Count} people remaining.");
  28.                     return;
  29.                 }
  30.                 else
  31.                 {
  32.  
  33.                     queue.Enqueue(command);
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement