Exemple #1
0
        private void Output(KingdomAnimal animal)
        {
            string name   = animal.Name;
            int    weight = animal.Weight;

            string output = $"{name}, {weight}кг\n";

            TBOutput.Text += output;
        }
Exemple #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();
            }
        }