private void CountSumWeight() { foreach (object animal in SupportingMethods.zoo) { if (animal is KingdomAnimal) { if (animal is ClassBirds) { if (selectedItem == 2) { ClassBirds bird = animal as ClassBirds; numberOfObjectsWithThisType++; sumWeight += bird.Weight; } continue; } if (animal is ClassMammals) { if (animal is OrderArtiodactyl) { if (selectedItem == 3) { OrderArtiodactyl artiodactyl = animal as OrderArtiodactyl; numberOfObjectsWithThisType++; sumWeight += artiodactyl.Weight; } continue; } if (selectedItem == 1) { ClassMammals mammal = animal as ClassMammals; numberOfObjectsWithThisType++; sumWeight += mammal.Weight; } continue; } if (selectedItem == 0) { KingdomAnimal being = animal as KingdomAnimal; numberOfObjectsWithThisType++; sumWeight += being.Weight; } } } }
private void BTAnimalCreate_Click(object sender, EventArgs e) { string name = Inputs.InputName(TBAnimalName.Text); if (name != null) { int weight = Inputs.InputWeight(TBAnimalWeight.Text); if (weight > 0) { KingdomAnimal animal = new KingdomAnimal(weight, name); SupportingMethods.zoo.Add(animal); animals.Add(animal); } } TBAnimalName.Clear(); TBAnimalWeight.Clear(); }