public void QueueAnimal(Node animal) { All.Enqueue(animal); if (animal.Value == Animal.Cat) { Cats.Enqueue(animal); } else { Dogs.Enqueue(animal); } }
public void EnqueueAnimal(PseudoNode animal) { All.Enqueue(animal); if (animal.Type == Animal.Cat) { Cats.Enqueue(animal); } else { Dogs.Enqueue(animal); } }
/// <summary> /// Stores an object that inherits from Animal. /// </summary> /// <param name="animal"> /// Animal: an object that inherits from Animal. /// </param> public void Enqueue(Animal animal) { animal.DateTimeCaptured = DateTime.Now; if (animal is Cat) { Cat cat = (Cat)animal; Cats.Enqueue(cat); } else if (animal is Dog) { Dog dog = (Dog)animal; Dogs.Enqueue(dog); } }
/// <summary> /// Takes in an Animal object, and checks if it is a Cat or Dog. If it is a Cat or Dog, it places it into a new CageNode with the current /// serial number, adds the CageNode to the Cats or Dogs Queue respectively, and iterates the NextSerial number, then returns true. /// If the given Animal isn't a Cat or Dog, does nothing and returns false. /// </summary> /// <param name="animal"></param> /// <returns> Boolean indicating whether given animal was added to the Animal Shelter </returns> public bool Enqueue(Animal animal) { if (animal is Dog) { CageNode newCage = new CageNode(animal, NextSerial); Dogs.Enqueue(newCage); NextSerial++; return(true); } else if (animal is Cat) { CageNode newCage = new CageNode(animal, NextSerial); Cats.Enqueue(newCage); NextSerial++; return(true); } else { return(false); } }