From TRCCompSci - AQA Computer Science
//This "else" statement has been added to increase the Reproduction Rate if the fox has eaten as much as, or more than, it needs.
if (FoodUnitsConsumedThisPeriod < FoodUnitsNeeded)
{
CalculateNewAge();
if (ShowDetail)
{
Console.WriteLine(" Fox ages further due to lack of food.");
}
}
else
{
ReproductionBonus = 0.3;
if (ShowDetail)
{
Console.WriteLine(" Fox wants some poon because he ate too much. Reproduction Rate increased by 0.3 for this turn.");
}
}
// To implement this change, a "ReproductionBonus" variable has been created within the fox class:
private double ReproductionBonus = 0;
//The new ReproductionBonus is implemented to affect the Reproduction Rate as shown below:
public bool ReproduceThisPeriod()
{
double ReproductionProbability = 0.25 + ReproductionBonus;
if (Rnd.Next(0, 100) < ReproductionProbability * 100)
{
return true;
}
else
{
return false;
}
}