コード例 #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 BTBirdCreate_Click(object sender, EventArgs e)
        {
            string name = Inputs.InputName(TBBirdName.Text);

            if (name != null)
            {
                int weight = Inputs.InputWeight(TBBirdWeight.Text);
                if (weight > 0)
                {
                    bool flying = false;
                    if (CBFlying.Checked)
                    {
                        flying = true;
                    }
                    bool domestic = false;
                    if (CBDomestic.Checked)
                    {
                        domestic = true;
                    }

                    ClassBirds bird = new ClassBirds(flying, domestic, weight, name);
                    SupportingMethods.zoo.Add(bird);
                    birds.Add(bird);
                }
                else
                {
                    SupportingMethods.ShowMistake(content: "Вес введен неверно");
                }
            }

            TBBirdName.Clear();
            TBBirdWeight.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();
        }
コード例 #4
0
ファイル: Search.cs プロジェクト: nimazein/LABA-10
 private void BTTriggerSearch_Click(object sender, EventArgs e)
 {
     if (!SupportingMethods.IsStringEmpty(TBName.Text) &&
         !SupportingMethods.IsStringEmpty(TBWeight.Text))
     {
         FindThisElement();
     }
     else
     {
         SupportingMethods.ShowMistake();
     }
 }
コード例 #5
0
 private void BTInputSize_Click(object sender, EventArgs e)
 {
     if (SupportingMethods.IsStringEmpty(TBInputSize.Text))
     {
         SupportingMethods.ShowMistake();
     }
     else
     {
         CreateArray();
         BTInputSize.Enabled = false;
         EnableButtons();
     }
 }
コード例 #6
0
        public static string InputName(string text)
        {
            string name = null;

            if (SupportingMethods.IsStringEmpty(text))
            {
                SupportingMethods.ShowMistake();
            }
            else
            {
                name = text;
            }
            return(name);
        }
コード例 #7
0
        private void BTCountMaxAge_Click(object sender, EventArgs e)
        {
            sumMaxAge     = 0;
            averageMaxAge = 0;
            numberOfObjectsWithThisType = 0;

            CountSumMaxAge();

            if (numberOfObjectsWithThisType == 0)
            {
                SupportingMethods.ShowMistake(content: "Не было создано ни одного животного");
                return;
            }
            CountAndOutputAverageMaxAge();
        }
コード例 #8
0
        private bool IsRightSize()
        {
            bool isRightSize = false;
            int  input       = Convert.ToInt32(TBInputSize.Text);

            if (input < 1 | input > 20)
            {
                SupportingMethods.ShowMistake(content: "Введен недопустимый размер");
            }
            else
            {
                isRightSize = true;
                size        = input;
            }
            return(isRightSize);
        }
コード例 #9
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();
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
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();
        }
コード例 #14
0
ファイル: Animals.cs プロジェクト: nimazein/LABA-10
        private void выводМассиваToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();

            if (animals.Count == 0)
            {
                SupportingMethods.ShowMistake(content: "Массив пуст");
            }
            else
            {
                foreach (KingdomAnimal animal in animals)
                {
                    int    weight = animal.Weight;
                    string name   = animal.Name;

                    string output = name + ", " + weight + "кг " + "\r\n";
                    richTextBox1.Text += output;
                }
            }
        }
コード例 #15
0
        private void BTAnimalCreate_Click(object sender, EventArgs e)
        {
            string name = Inputs.InputName(TBMammalName.Text);

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

                    if (incubationPeriod > 0)
                    {
                        int lifeExtrancy = Inputs.InputLifeExpectancy(TBMaxAge.Text);
                        if (lifeExtrancy > 0)
                        {
                            ClassMammals mammal = new ClassMammals(incubationPeriod, lifeExtrancy, weight, name);
                            SupportingMethods.zoo.Add(mammal);
                            mammals.Add(mammal);
                        }
                        else
                        {
                            SupportingMethods.ShowMistake("Продолжительность жизни введена неверно");
                        }
                    }
                    else
                    {
                        SupportingMethods.ShowMistake("Период вынашивания введен неверно");
                    }
                }
                else
                {
                    SupportingMethods.ShowMistake(content: "Вес введен неверно");
                }
            }

            TBIncubationPeriod.Clear();
            TBMammalName.Clear();
            TBMammalWeight.Clear();
            TBMaxAge.Clear();
        }
コード例 #16
0
        private void BTCountWeight_Click(object sender, EventArgs e)
        {
            if (SupportingMethods.zoo.Count == 0)
            {
                SupportingMethods.ShowMistake(content: "Массив пуст");
                return;
            }
            sumWeight = 0;
            numberOfObjectsWithThisType = 0;
            TBOutputWeight.Clear();
            selectedItem = comboBox1.SelectedIndex;

            CountSumWeight();
            if (numberOfObjectsWithThisType == 0)
            {
                SupportingMethods.ShowMistake(content: "Объектов такого типа в массиве нет");
                return;
            }

            CountAndOutputAverageWeight();
        }
コード例 #17
0
        private void выводМассиваToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();

            if (birds.Count == 0)
            {
                SupportingMethods.ShowMistake(content: "Массив пуст");
            }
            else
            {
                foreach (ClassBirds bird in birds)
                {
                    int    weight   = bird.Weight;
                    string name     = bird.Name;
                    bool   flying   = bird.Flying;
                    bool   domestic = bird.Domestic;

                    string output = name + ", " + weight + "кг, " + "летает: " + flying + ", домашняя: " + domestic + "\r\n";
                    richTextBox1.Text += output;
                }
            }
        }
コード例 #18
0
        private void выводМассиваToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();

            if (mammals.Count == 0)
            {
                SupportingMethods.ShowMistake(content: "Массив пуст");
            }
            else
            {
                foreach (ClassMammals mammal in mammals)
                {
                    int    weight           = mammal.Weight;
                    string name             = mammal.Name;
                    int    incubationPeriod = mammal.IncubationPeriod;
                    int    maxAge           = mammal.LifeExpectancy;

                    string output = name + ", " + weight + "кг, " + incubationPeriod + " месяцев, " + maxAge + " лет" + "\r\n";
                    richTextBox1.Text += output;
                }
            }
        }
コード例 #19
0
        private void выводМассиваToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            if (artiodactyls.Count == 0)
            {
                SupportingMethods.ShowMistake(content: "Массив пуст");
            }
            else
            {
                foreach (OrderArtiodactyl artiodactyl in artiodactyls)
                {
                    int    weight           = artiodactyl.Weight;
                    string name             = artiodactyl.Name;
                    int    incubationPeriod = artiodactyl.IncubationPeriod;
                    int    maxAge           = artiodactyl.LifeExpectancy;
                    bool   horns            = artiodactyl.HasHorns;
                    string habitat          = artiodactyl.Habitat;

                    string output = name + ", " + weight + "кг, " + incubationPeriod + " месяцев, " + maxAge + " лет, " + "есть рога: " + horns + ", " + habitat + "\r\n";
                    richTextBox1.Text += output;
                }
            }
        }
コード例 #20
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();
        }