Difference between revisions of "In queue class definition, make use of the IsEmpty method in Show method"
m |
(I did not, maybe now I have) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | If I understand this | + | 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#"> | <syntaxhighlight lang="C#"> | ||
− | if (!IsEmpty()) | + | public void Show(){ |
+ | if (!IsEmpty())//This has changed from Rear != -1 | ||
{ | { | ||
Console.WriteLine(); | Console.WriteLine(); | ||
Line 11: | Line 12: | ||
} | } | ||
Console.WriteLine(); | Console.WriteLine(); | ||
+ | } | ||
+ | } | ||
</syntaxhighlight> | </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();
}
}