public void createAnimal(int speciesIndex, string named, int age, int categoryIndex, int genderIndex) { animalis = castAnimal(speciesIndex, (CategoryType)categoryIndex); animalis.name = named; animalis.Age = age; animalis.Category = (CategoryType)categoryIndex; animalis.Gender = (GenderType)genderIndex; animalis.Species = getSpeciesStr(animalis); apuResidents.Add(animalis); }
/// <summary> /// Method Adds animal overriden /// </summary> /// <param name="customerIn"></param> /// <returns>true if the customer added successfully</returns> public bool AddAnimal(Animal animalItem) { if (Count + 2 >= 0 && Convert.ToInt32(animalItem.ID) < m_animals.Count) { m_animals.Add(animalItem); animalItem.ID = GetNewID.ToString(); return true; } else { return false; } }
/// <summary> /// Add a new object to the list. /// The object will be appended to the /// end of the list. /// </summary> /// <param name="FoodItem">The object to be added.</param> /// <returns>The number of items in the list - as an extra info.</returns> /// <remarks></remarks> public int Add(Animal animalItem) { string newID = GetNewID.ToString(); m_animals.Add(animalItem); return m_animals.Count; }
/// <summary> /// Returns the class type as string /// </summary> /// <param name="ani">Animal object</param> /// <returns>Animal object type string</returns> private string getSpeciesStr(Animal ani) { string outCat = ani.ToString(); return outCat; }
private Animal castAnimal(int speciesIndex, CategoryType type) { //Checking which object to create: if (type == CategoryType.Bird) { BirdSpecies speciestype = (BirdSpecies)speciesIndex; animalis = BirdFactory.CreateBird(speciestype); } else if (type == CategoryType.Insect) { InsectSpecies insectSpec = (InsectSpecies)speciesIndex; animalis = InsectFactory.CreateInsect(insectSpec); } else if (type == CategoryType.Mammal) { MammalSpecies mammalSpec = (MammalSpecies)speciesIndex; animalis = MammalFactory.CreateMammal(mammalSpec); } else if (type == CategoryType.Marine) { MarineSpecies marineSpec = (MarineSpecies)speciesIndex; animalis = MarineFactory.CreateMarine(marineSpec); } else if (type == CategoryType.Reptile) { ReptileSpecies reptileSpec = (ReptileSpecies)speciesIndex; animalis = ReptileFactory.CreateReptile(reptileSpec); } return animalis; }