In queue class definition, make use of the IsEmpty method in Show method

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

If I understand this correctly, all you need to do is replace the condition within the if statement in the Show method, with !IsEmpty.

            public void Show(){
                if (!IsEmpty())//This has changed from Rear != -1
                {
                    Console.WriteLine();
                    Console.Write("The contents of the queue are: ");
                    foreach (var item in Contents)
                    {
                        Console.Write(item);
                    }
                    Console.WriteLine();
                }
            }