Пример #1
0
        private void BTArtiodactylCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBArtiodactylName.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylWeight.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylMaxAge.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylIncubationPeriod.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylHabitat.Text))
            {
                string name             = TBArtiodactylName.Text;
                int    weight           = Convert.ToInt32(TBArtiodactylWeight.Text);
                int    incubationPeriod = Convert.ToInt32(TBArtiodactylIncubationPeriod.Text);
                int    lifeExpectancy   = Convert.ToInt32(TBArtiodactylMaxAge.Text);
                bool   hasHorns         = CBHorns.Checked;
                string habitat          = TBArtiodactylHabitat.Text;

                InsertArtiodactylToArray(name, weight, incubationPeriod, lifeExpectancy, hasHorns, habitat);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBArtiodactylHabitat.Clear();
            TBArtiodactylIncubationPeriod.Clear();
            TBArtiodactylMaxAge.Clear();
            TBArtiodactylName.Clear();
            TBArtiodactylWeight.Clear();
        }
Пример #2
0
        private void BTArtiodactylCreate_Click(object sender, EventArgs e)
        {
            string name = Inputs.InputName(TBArtiodactylName.Text);

            if (name != null)
            {
                int weight = Inputs.InputWeight(TBArtiodactylWeight.Text);
                if (weight > 0)
                {
                    int incubationPeriod = Inputs.InputIncubationPeriod(TBArtiodactylIncubationPeriod.Text);

                    if (incubationPeriod > 0)
                    {
                        int lifeExpectancy = Inputs.InputLifeExpectancy(TBArtiodactylMaxAge.Text);
                        if (lifeExpectancy > 0)
                        {
                            bool horns = false;
                            if (checkBox1.Checked)
                            {
                                horns = true;
                            }

                            if (SupportingMethods.IsStringEmpty(TBArtiodactylHabitat.Text))
                            {
                                SupportingMethods.ShowMistake();
                            }
                            else
                            {
                                string           habitat     = TBArtiodactylHabitat.Text;
                                OrderArtiodactyl artiodactyl = new OrderArtiodactyl(horns, habitat, incubationPeriod, lifeExpectancy, weight, name);
                                SupportingMethods.zoo.Add(artiodactyl);
                                artiodactyls.Add(artiodactyl);
                            }
                        }
                        else
                        {
                            SupportingMethods.ShowMistake("Продолжительность жизни введена неверно");
                        }
                    }
                    else
                    {
                        SupportingMethods.ShowMistake("Период вынашивания введен неверно");
                    }
                }
                else
                {
                    SupportingMethods.ShowMistake(content: "Вес введен неверно");
                }
            }
            TBArtiodactylHabitat.Clear();
            TBArtiodactylIncubationPeriod.Clear();
            TBArtiodactylMaxAge.Clear();
            TBArtiodactylName.Clear();
            TBArtiodactylWeight.Clear();
        }
Пример #3
0
 private void BTTriggerSearch_Click(object sender, EventArgs e)
 {
     if (!SupportingMethods.IsStringEmpty(TBName.Text) &&
         !SupportingMethods.IsStringEmpty(TBWeight.Text))
     {
         FindThisElement();
     }
     else
     {
         SupportingMethods.ShowMistake();
     }
 }
Пример #4
0
 private void BTInputSize_Click(object sender, EventArgs e)
 {
     if (SupportingMethods.IsStringEmpty(TBInputSize.Text))
     {
         SupportingMethods.ShowMistake();
     }
     else
     {
         CreateArray();
         BTInputSize.Enabled = false;
         EnableButtons();
     }
 }
Пример #5
0
        public static string InputName(string text)
        {
            string name = null;

            if (SupportingMethods.IsStringEmpty(text))
            {
                SupportingMethods.ShowMistake();
            }
            else
            {
                name = text;
            }
            return(name);
        }
Пример #6
0
        private void BTAnimalCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBAnimalName.Text) &&
                !SupportingMethods.IsStringEmpty(TBAnimalWeight.Text))
            {
                string name   = TBAnimalName.Text;
                int    weight = Convert.ToInt32(TBAnimalWeight.Text);

                InsertAnimalToArray(name, weight);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBAnimalName.Clear();
            TBAnimalWeight.Clear();
        }
Пример #7
0
        public static int InputLifeExpectancy(string text)
        {
            int lifeExpectancy = -1;

            if (SupportingMethods.IsStringEmpty(text))
            {
                SupportingMethods.ShowMistake();
            }
            else
            {
                int input = Convert.ToInt32(text);
                if (input != 0 && input < 200)
                {
                    lifeExpectancy = input;
                }
            }
            return(lifeExpectancy);
        }
Пример #8
0
        public static int InputIncubationPeriod(string text)
        {
            int incubationPeriod = -1;

            if (SupportingMethods.IsStringEmpty(text))
            {
                SupportingMethods.ShowMistake();
            }
            else
            {
                int input = Convert.ToInt32(text);
                if (input != 0 && input < 50)
                {
                    incubationPeriod = input;
                }
            }
            return(incubationPeriod);
        }
Пример #9
0
        public static int InputWeight(string text)
        {
            int weight = -1;

            if (SupportingMethods.IsStringEmpty(text))
            {
                SupportingMethods.ShowMistake();
            }
            else
            {
                int input = Convert.ToInt32(text);
                if (SupportingMethods.IsRightWeight(input))
                {
                    weight = input;
                }
            }
            return(weight);
        }
Пример #10
0
        private void BTBirdCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBBirdName.Text) &&
                !SupportingMethods.IsStringEmpty(TBBirdWeight.Text))
            {
                string name     = TBBirdName.Text;
                int    weight   = Convert.ToInt32(TBBirdWeight.Text);
                bool   flying   = CBFlying.Checked;
                bool   domestic = CBDomestic.Checked;

                InsertBirdToArray(name, weight, flying, domestic);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBBirdWeight.Clear();
            TBBirdName.Clear();
        }
Пример #11
0
        private void BTMammalCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBMammalName.Text) &&
                !SupportingMethods.IsStringEmpty(TBMammalWeight.Text) &&
                !SupportingMethods.IsStringEmpty(TBMammalMaxAge.Text) &&
                !SupportingMethods.IsStringEmpty(TBMammalIncubationPeriod.Text))
            {
                string name             = TBMammalName.Text;
                int    weight           = Convert.ToInt32(TBMammalWeight.Text);
                int    incubationPeriod = Convert.ToInt32(TBMammalIncubationPeriod.Text);
                int    lifeExpectancy   = Convert.ToInt32(TBMammalMaxAge.Text);

                InsertMammalToArray(name, weight, incubationPeriod, lifeExpectancy);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBMammalWeight.Clear();
            TBMammalName.Clear();
            TBMammalMaxAge.Clear();
            TBMammalIncubationPeriod.Clear();
        }