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
m
m
Line 2: Line 2:
  
 
<syntaxhighlight lang="C#">
 
<syntaxhighlight lang="C#">
 +
            public void Show(){
 
                 if (!IsEmpty())//This has changed from Rear != -1
 
                 if (!IsEmpty())//This has changed from Rear != -1
 
                 {
 
                 {
Line 12: Line 13:
 
                     Console.WriteLine();
 
                     Console.WriteLine();
 
                 }
 
                 }
 +
            }
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 15:21, 24 May 2018

If I understand this correct it would be replace the condition within the if statement in Show, 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();
                }
            }