Difference between revisions of "In queue class definition, make use of the IsEmpty method in Show method"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "If I understand this correct it would be replace the condition within the if statement in Show, with !IsEmpty.")
 
(I did not, maybe now I have)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
If I understand this correct it would be replace the condition within the if statement in Show, with !IsEmpty.
+
If I understand this correctly, all you need to do is replace the condition within the if statement in the Show method, with !IsEmpty.
 +
 
 +
<syntaxhighlight lang="C#">
 +
            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();
 +
                }
 +
            }
 +
</syntaxhighlight>

Latest revision as of 15:23, 24 May 2018

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();
                }
            }