Example #1
0
        private void Output(ClassMammals animal)
        {
            string name             = animal.Name;
            int    weight           = animal.Weight;
            int    incubationPeriod = animal.IncubationPeriod;
            int    lifeExpectancy   = animal.LifeExpectancy;

            string output = $"{name}, {weight}кг, {incubationPeriod}месяцев, {lifeExpectancy}лет\n";

            TBOutput.Text += output;
        }
Example #2
0
        private void BTFind_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBKey.Text))
            {
                string key             = TBKey.Text;
                object soughtForAnimal = Collections.FindByKey(key);

                if (soughtForAnimal != null)
                {
                    if (key.Contains("Животное"))
                    {
                        KingdomAnimal animal = soughtForAnimal as KingdomAnimal;
                        Output(animal);
                    }
                    if (key.Contains("Млекопитающее"))
                    {
                        ClassMammals mammal = soughtForAnimal as ClassMammals;
                        Output(mammal);
                    }
                    if (key.Contains("Птица"))
                    {
                        ClassBirds bird = soughtForAnimal as ClassBirds;
                        Output(bird);
                    }
                    if (key.Contains("Парнокопытное"))
                    {
                        OrderArtiodactyl artiodactyl = soughtForAnimal as OrderArtiodactyl;
                        Output(artiodactyl);
                    }
                }
            }
            else
            {
                SupportingMethods.ShowMistake();
            }
        }