Пример #1
0
        private void BTArtiodactylCreate_Click(object sender, EventArgs e)
        {
            if (Main.animals.Count >= Main.animals.Capacity)
            {
                support.ShowInfo("Коллекция расширена");
                Main.animals.ExpandCollection();
            }

            if (!support.IsStringEmpty(TBArtiodactylName.Text) &&
                !support.IsStringEmpty(TBArtiodactylWeight.Text) &&
                !support.IsStringEmpty(TBArtiodactylMaxAge.Text) &&
                !support.IsStringEmpty(TBArtiodactylIncubationPeriod.Text) &&
                !support.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;

                Main.animals.Enqueue(new OrderArtiodactyl(hasHorns, habitat, incubationPeriod, lifeExpectancy, weight, name));
            }
            else
            {
                support.ShowMistake();
            }

            TBArtiodactylHabitat.Clear();
            TBArtiodactylIncubationPeriod.Clear();
            TBArtiodactylMaxAge.Clear();
            TBArtiodactylName.Clear();
            TBArtiodactylWeight.Clear();
        }
Пример #2
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();
        }
Пример #3
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();
        }