private void OnCLEMAnimalBreeding(object sender, EventArgs e) { if (this.TimingOK) { double malebreeders = SelectedOtherAnimalsType.Cohorts.Where(a => a.Age >= this.BreedingAge && a.Sex == Sex.Male).Sum(b => b.Number); if (!UseLocalMales || malebreeders > 0) { // get number of females double breeders = SelectedOtherAnimalsType.Cohorts.Where(a => a.Age >= this.BreedingAge && a.Sex == Sex.Female).Sum(b => b.Number); // create new cohorts (male and female) if (breeders > 0) { double newbysex = breeders * this.OffspringPerBreeder / 2.0; OtherAnimalsTypeCohort newmales = new OtherAnimalsTypeCohort() { Age = 0, Weight = 0, Sex = Sex.Male, Number = newbysex, SaleFlag = HerdChangeReason.Born }; SelectedOtherAnimalsType.Add(newmales, this, SelectedOtherAnimalsType.NameWithParent, "Births"); OtherAnimalsTypeCohort newfemales = new OtherAnimalsTypeCohort() { Age = 0, Weight = 0, Sex = Sex.Female, Number = newbysex, SaleFlag = HerdChangeReason.Born }; SelectedOtherAnimalsType.Add(newfemales, this, SelectedOtherAnimalsType.NameWithParent, "Births"); } } } }
private void OnWFAnimalBreeding(object sender, EventArgs e) { if (this.NextDueDate.Month == Clock.Today.Month) { double malebreeders = SelectedOtherAnimalsType.Cohorts.Where(a => a.Age >= this.BreedingAge & a.Gender == Sex.Male).Sum(b => b.Number); if (!UseLocalMales ^ malebreeders > 0) { // get nuber of females double breeders = SelectedOtherAnimalsType.Cohorts.Where(a => a.Age >= this.BreedingAge & a.Gender == Sex.Female).Sum(b => b.Number); // create new cohorts (male and female) if (breeders > 0) { double newbysex = breeders * this.OffspringPerBreeder / 2.0; OtherAnimalsTypeCohort newmales = new OtherAnimalsTypeCohort() { Age = 0, Weight = 0, Gender = Sex.Male, Number = newbysex, SaleFlag = Common.HerdChangeReason.Born }; SelectedOtherAnimalsType.Add(newmales, this.Name, SelectedOtherAnimalsType.Name); OtherAnimalsTypeCohort newfemales = new OtherAnimalsTypeCohort() { Age = 0, Weight = 0, Gender = Sex.Female, Number = newbysex, SaleFlag = Common.HerdChangeReason.Born }; SelectedOtherAnimalsType.Add(newfemales, this.Name, SelectedOtherAnimalsType.Name); } } this.NextDueDate = this.NextDueDate.AddMonths(this.BreedingInterval); } }