// Try to de-Q again?
try
{ WashCar((Car)carWashQ.Dequeue()); }
catch(Exception e)
{ Console.WriteLine("Error!! {0}", e.Message);}
}
Here, you insert three items into the Queue type via its Enqueue() method. The call to Peek()
allows you to view (but not remove) the first item currently in the Queue, which in this case is the
object named FirstCar. Finally, the call to Dequeue() removes the item from the line and sends it
into the WashCar() helper function for processing. Do note that if you attempt to remove items from
an empty queue, a runtime exception is thrown.
Do'stlaringiz bilan baham: |