Exemplo n.º 1
0
        /// <summary>
        /// Populate the animal list with some pre-prepared animals.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPopulate_Click(object sender, EventArgs e)
        {
            var someAnimals = AnimalHelper.makeSomeAnimals();

            foreach (var animal in someAnimals)
            {
                _animalManager.Add(animal);
            }
            UpdateTable();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when the Add button is clicked. Adds an animal, if appropriate.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var name             = txtName.Text;
            var ageString        = txtAge.Text;
            var gender           = (Gender)lbxGender.SelectedIndex;
            var categoryProperty = txtCatProperty.Text;
            var speciesProperty  = txtSpeciesProperty.Text;
            var species          = lbxAnimalObject.SelectedItem.ToString();

            var ageOk = int.TryParse(ageString, out var age);

            var argumentsOk = ageOk;

            if (argumentsOk)
            {
                _animalManager.Add(AnimalHelper.MakeAnimal(name, age, gender, categoryProperty, speciesProperty, species));
            }


            UpdateTable();
        }