/// <summary>
 /// Dequeues a specific animal type or the oldest animal.
 /// </summary>
 /// <param name="type">the Type of animal</param>
 /// <returns>The oldest animal of the requested type</returns>
 public Node <DateTime> Dequeue(string type = null)
 {
     if (type == "dog")
     {
         return(Dogs.Dequeue());
     }
     else if (type == "cat")
     {
         return(Cats.Dequeue());
     }
     else
     {
         return((Dogs.Peek().Data.CompareTo(Cats.Peek().Data) < 0)? Dogs.Dequeue() : Cats.Dequeue());
     }
 }
Beispiel #2
0
 public Animal Dequeue(string pref)
 {
     if (pref.ToLower() == "cat")
     {
         if (Cats.Peek() != null)
         {
             return(Cats.Dequeue().Holds);
         }
     }
     else if (pref.ToLower() == "dog")
     {
         if (Dogs.Peek() != null)
         {
             return(Dogs.Dequeue().Holds);
         }
     }
     return(null);
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public Animal Dequeue()
 {
     if (Dogs.Peek() != null && Cats.Peek() != null)
     {
         return(Dogs.Peek().Serial < Cats.Peek().Serial ? Dogs.Dequeue().Holds : Cats.Dequeue().Holds);
     }
     else if (Dogs.Peek() == null && Cats.Peek() == null)
     {
         return(null);
     }
     else if (Dogs.Peek() == null)
     {
         return(Cats.Dequeue().Holds);
     }
     else
     {
         return(Dogs.Dequeue().Holds);
     }
 }