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(); }
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(); }
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(); }
private void BTTriggerSearch_Click(object sender, EventArgs e) { if (!SupportingMethods.IsStringEmpty(TBName.Text) && !SupportingMethods.IsStringEmpty(TBWeight.Text)) { FindThisElement(); } else { SupportingMethods.ShowMistake(); } }
private void BTInputSize_Click(object sender, EventArgs e) { if (SupportingMethods.IsStringEmpty(TBInputSize.Text)) { SupportingMethods.ShowMistake(); } else { CreateArray(); BTInputSize.Enabled = false; EnableButtons(); } }
public static string InputName(string text) { string name = null; if (SupportingMethods.IsStringEmpty(text)) { SupportingMethods.ShowMistake(); } else { name = text; } return(name); }
private void BTCountMaxAge_Click(object sender, EventArgs e) { sumMaxAge = 0; averageMaxAge = 0; numberOfObjectsWithThisType = 0; CountSumMaxAge(); if (numberOfObjectsWithThisType == 0) { SupportingMethods.ShowMistake(content: "Не было создано ни одного животного"); return; } CountAndOutputAverageMaxAge(); }
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); }
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(); }
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); }
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); }
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); }
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(); }
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; } } }
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(); }
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(); }
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; } } }
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; } } }
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; } } }
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(); }