public static void PrintStatusForQueue(SmartQueue.SmartQueue myQueue, string eventText) { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Write($" Number of elements after {eventText}: "); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine(myQueue.Count); Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine($" Elements after {eventText}:"); Console.ForegroundColor = ConsoleColor.DarkYellow; foreach (var item in myQueue) { Console.Write($" {item}"); } Console.WriteLine(); Console.WriteLine(); }
static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Clear(); // only Chuck SmartQueue smartQueue = new SmartQueue(); //Console.ForegroundColor = ConsoleColor.DarkYellow; Presenter.PrintStatusForQueue(smartQueue, "SmartQueue for Chuck created"); Console.WriteLine($" {smartQueue.ToString()}"); Console.WriteLine(); // only Dutch and Chuck of course SmartQueue smartQueueForDutch = new SmartQueue(Country.Dutch); smartQueueForDutch.Enqueue(); // "Chuck Norris" smartQueueForDutch.Enqueue("William-Alexander"); smartQueueForDutch.Enqueue("Juliana"); Console.WriteLine($" {smartQueueForDutch.ToString()}"); Presenter.PrintStatusForQueue(smartQueueForDutch, "SmartQueue filled up."); smartQueueForDutch.Dequeue(); smartQueueForDutch.Dequeue(); smartQueueForDutch.Dequeue(); smartQueueForDutch.Dequeue(); Presenter.PrintStatusForQueue(smartQueueForDutch, "queue emptyed with four \"Dequeue()\""); Console.WriteLine($" {smartQueueForDutch.ToString()}"); Console.WriteLine(); try { smartQueue.Enqueue("Marcika"); } catch (Exception ex) { Console.WriteLine($" {ex.Message}"); } Console.ReadKey(); }