/// <summary>
 /// Retrieves an Animal in FIFO ordering, based off the string parameter "pref":
 /// <para>
 /// If pref is "cat" and there are Cats in the shelter, returns the cat that's been the shelter the longest. If there are no cats in the shelter, returns null.
 /// </para>
 /// <para>
 /// If pref is "dog" and there are Dogs in the shelter, returns the dog that's been the shelter the longest. If there are no dogs in the shelter, returns null.
 /// </para>
 /// <para>
 /// If pref is "no preference" and there are Cats or Dogs in the shelter, returns whichever has been in the shelter the longest. If there are only Cats or Dogs, returns the animal that's been in the shelter the longest. If no animals are in the shelter, returns null.
 /// </para>
 /// </summary>
 /// <param name="pref">
 /// string: the preferred animal
 /// </param>
 /// <returns>
 /// Animal: the animal released from the shelter
 /// </returns>
 public Animal Dequeue(string pref)
 {
     if (pref == "no preference" && (PeekCats() != null || PeekDogs() != null))
     {
         if (PeekCats() != null && PeekDogs() != null)
         {
             DateTime oldestCat = PeekCats().DateTimeCaptured;
             DateTime oldestDog = PeekDogs().DateTimeCaptured;
             return(oldestCat < oldestDog ? (Animal)Cats.Dequeue() : (Animal)Dogs.Dequeue());
         }
         else if (PeekCats() != null)
         {
             return((Animal)Cats.Dequeue());
         }
         else
         {
             return((Animal)Dogs.Dequeue());
         }
     }
     else if (pref == "cat" && PeekCats() != null)
     {
         return((Animal)Cats.Dequeue());
     }
     else if (pref == "dog" && PeekDogs() != null)
     {
         return((Animal)Dogs.Dequeue());
     }
     return(null);
 }
Exemplo n.º 2
0
        public void DequeueDog()
        {
            //Remove from the dog list.
            var adoptedDog = Dogs.Dequeue();

            //Then remove from the overall list.
            All.DequeueAny(adoptedDog);
        }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 5
0
        public void DequeueDog()
        {
            var dogNoMore = Dogs.Dequeue();

            All.DequeueOne(dogNoMore);
        }