/// <summary> /// This method is responsible for adding the animals to the listbox on the form, and their images to 4 listboxes /// (if there are 4 or less of the particular animal). /// </summary> /// <param name="animals">The list of animals to add to the listbox and pictureboxes.</param> /// <param name="type">The type of animal</param> /// <param name="pictureBoxes">An array of listboxes to add the animals' images to.</param> public void addAnimalsToLBandImages(List<IAnimal> animals, AnimalTypes.animalTypes type, PictureBox[] pictureBoxes) { ///<summary> ///Clear any previously added animals ///and pictures from the form. animalListBox.Items.Clear(); foreach (PictureBox p in pictureBoxes) { p.Image = null; } List<IAnimal> displayImageAnimals = new List<IAnimal>(); ///<summary> ///This loop goes through each animal currently in the list, ///and adds the name + species of animal to the form listbox. ///<summary> for (int i = 0; i < animals.Count; i++ ) { if (animals[i].getType() == type) { animalListBox.Items.Add(animals[i].ToString()); displayImageAnimals.Add(animals[i]); } } ///<summary> ///If there are 4 or less animals in this list, ///display each of their images to the form. ///</summary> if (displayImageAnimals.Count <= 4) { for (int i = 0; i < displayImageAnimals.Count; i++) { pictureBoxes[i].Image = displayImageAnimals[i].getImage(); } } }
/// <summary> /// Constructor - sets and initialises the name and /// type of the animal to be created. /// </summary> /// <param name="name">The name of the animal.</param> /// <param name="type">The animal's type (species).</param> public Animal(string name, AnimalTypes.animalTypes type) { this.name = name; this.type = type; }
public void AnimalTypesConstructorTest() { AnimalTypes target = new AnimalTypes(); Assert.Inconclusive("TODO: Implement code to verify target"); }