/// <summary>
        /// Get selected animal
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBoxAnimals_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = listBoxAnimals.SelectedIndex;

            if (index >= 0)
            {
                Animal animal = animalmanager.GetAt(index);
                textBoxName.Text            = animal.Name;
                textBoxAge.Text             = animal.Age.ToString();
                listBoxGender.SelectedIndex = (int)animal.Gender;
                string common   = string.Empty;
                string specific = string.Empty;
                int    category = 0;
                int    specie   = 0;
                if (animal is Cattle)
                {
                    category = (int)Category.Mammals;
                    specie   = (int)Specie_Mammal.Cattle;
                    common   = ((Cattle)animal).Weight.ToString();
                    specific = ((Cattle)animal).Height.ToString();
                }
                if (animal is Horse)
                {
                    category = (int)Category.Mammals;
                    specie   = (int)Specie_Mammal.Horse;
                    common   = ((Horse)animal).Weight.ToString();
                    specific = ((Horse)animal).Breed.ToString();
                }
                if (animal is Chameleon)
                {
                    category = (int)Category.Reptiles;
                    specie   = (int)Specie_Reptile.Chameleon;
                    common   = ((Chameleon)animal).Length.ToString();
                    specific = ((Chameleon)animal).Colour.ToString();
                }
                if (animal is Crocodile)
                {
                    category = (int)Category.Reptiles;
                    specie   = (int)Specie_Reptile.Crocodile;
                    common   = ((Crocodile)animal).Length.ToString();
                    specific = ((Crocodile)animal).TailLength.ToString();
                }
                if (animal is Turtle)
                {
                    category = (int)Category.Reptiles;
                    specie   = (int)Specie_Reptile.Turtle;
                    common   = ((Turtle)animal).Length.ToString();
                    specific = ((Turtle)animal).Speed.ToString();
                }
                textBoxEaterType.Text = animal.GetEaterType().ToString();
                FoodSchedule foodSchedule = animal.GetFoodSchedule();
                textBoxFeedingSchedule.Text   = foodSchedule.ToString();
                listBoxCategory.SelectedIndex = category;
                listBoxSpecies.SelectedIndex  = specie;
                textBoxCommonCatSpec.Text     = common;
                textBoxSpecificCatSpec.Text   = specific;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Return feedingschedule
        /// </summary>
        /// <returns></returns>
        public override FoodSchedule GetFoodSchedule()
        {
            List <string> feedingschedule = new List <string>();

            foreach (string row in this.feedingschedule)
            {
                feedingschedule.Add(row);
            }
            FoodSchedule foodSchedule = new FoodSchedule(feedingschedule);

            return(foodSchedule);
        }