public void NewChild(Person child) { myThoughtBubble+="\nMy new child is " + child.ToString(); myChildrensNames.Add(child.Name); }
public void Next(double vDate, ProgressBar pb) { List<bool> tracker = new List<bool>(this.Size()); int t; pb.Maximum = this.Size(); for (int i = 0; i < this.Size(); i++) { itsList[i].Next(vDate); pb.Value = i+1; } for (int i = 0; i < tracker.Capacity; i++) { tracker.Add(new bool()); } itsMessage += "\n================" + "\nDate: " + vDate.ToString("N1"); pb.Maximum = this.Size(Gender.Male); for (int i = 0; i < this.Size(Gender.Male); i++) { //pb.Value = i; do { t = r.Next(0, this.Size(Gender.Male)); } while (tracker[t]); tracker[t] = true; for (int j = 0; j < this.Size(Gender.Female); j++) { itsMales[t].Meet(itsFemales[j]); } if (itsList[i].HadABaby) { Person dad = itsList[i].BabyDaddy; Person baby = new Person(itsList[i], dad); itsList.Add(baby); if (baby.GetGender == Gender.Male) { itsMales.Add(baby); } else { itsFemales.Add(baby); } itsMessage += "\n" + itsList[i].Name.ToString() + " & " + dad.Name.ToString() + " had a baby!\nWelcome: " + baby.ToString(); } if ((i+1) > pb.Maximum) { pb.Value = pb.Maximum; } else { pb.Value = i+1; } } pb.Maximum = this.Size(); for (int i = 0; i < this.Size(); i++) { if (i < this.Size()) { if (itsList[i].Dead) { itsMessage += "\n" + itsList[i].ToString() + " has died."; if (itsList[i].GetGender == Gender.Male) { itsMales.Remove(itsList[i]); } else { itsFemales.Remove(itsList[i]); } itsList.Remove(itsList[i]); i--; } } if ((i+1) > pb.Maximum) { pb.Value = pb.Maximum; } else { pb.Value = i+1; } } itsMessage += "\nPopulation: " + this.Size().ToString() + " (Males: " + this.Size(Gender.Male).ToString() + ", Females: " + this.Size(Gender.Female).ToString() + ")"; }