/// <summary> /// Add the babies stored in the Babies list to the main list. This is an /// internal method that may only be called by classes in the Rabies_Model_Core /// namespace. /// </summary> /// <param name="EHandler">An event handler for the AnimalInfected event.</param> internal void AddBabiesToList(AnimalInfectedEventHandler EHandler) { //System.Diagnostics.Debug.WriteLine(""); //System.Diagnostics.Debug.WriteLine("cMasterAnimalList.cs: AddBabiesToList()"); if (Babies.Count > 0) { // loop through all animals in the babies list foreach (cAnimal BabyAnimal in Babies) { // set the event handler if (EHandler != null) { BabyAnimal.AnimalInfected += EHandler; } // add to main list this.Add(BabyAnimal); // add to all animals list if (mvarKeepAllAnimals) { AllAnimals.Add(BabyAnimal); } } // destroy this version of the BabyAnimal list and create a new one Babies = new cAnimalList(null); } }
public void Run() { string command = Console.ReadLine(); AllAnimals animals = new AllAnimals(); while (command != "End") { string[] animalInfo = command.Split(); string[] foodInfo = Console.ReadLine().Split(); string animalType = animalInfo[0]; string name = animalInfo[1]; double weight = double.Parse(animalInfo[2]); string foodType = foodInfo[0]; int quantity = int.Parse(foodInfo[1]); FoodFactory foodFactory = new FoodFactory(quantity, foodType); Food food = foodFactory.CheckFood(); AnimalFactory animalFactory = new AnimalFactory(animalType, name, weight, quantity, food, animalInfo); Animal animal = animalFactory.CheckAnimal(); animals.Add(animal); command = Console.ReadLine(); } animals.Print(); }
public void AddAnimal() { //Instantiate animal, connect event handler, add animal to collection. var tempAnimal = GetAnimal(SelctAddType); tempAnimal.IsStarving += Animal_IsStarving; tempAnimal.HasDied += Animal_HasDied; AllAnimals.Add(tempAnimal); }
/// <summary> /// Add the babies stored in the Babies list to the main list. This is an /// internal method that may only be called by classes in the Rabies_Model_Core /// namespace. /// </summary> internal void AddBabiesToList() { if (Babies.Count > 0) { // loop through all animals in the babies list foreach (cAnimal BabyAnimal in Babies) { // add to main list this.Add(BabyAnimal); // add to all animals list if (mvarKeepAllAnimals) { AllAnimals.Add(BabyAnimal); } } // destroy this version of the BabyAnimal list and create a new one Babies = new cAnimalList(null); } }