The following code is given:
class Warren
{
private const int MaxRabbitsInWarren = 99;
private Rabbit[] Rabbits;
private int RabbitCount = 0;
private int PeriodsRun = 0;
private bool AlreadySpread = false;
private int Variability;
private static Random Rnd = new Random();
public Warren(int Variability)
{
this.Variability = Variability;
Rabbits = new Rabbit[MaxRabbitsInWarren];
RabbitCount = (int)(CalculateRandomValue((int)(MaxRabbitsInWarren / 4), this.Variability));
for (int r = 0; r < RabbitCount; r++)
{
Rabbits[r] = new Rabbit(Variability);
}
}
}
- There is an array called Rabbits, of type Rabbit, which is a field of class Warren.
- The Warren constructor creates a random number of ‘Rabbits’ to be placed in the Rabbits array.
Because the array Rabbits is a member of the Warren class, does this means that its lifecycle is tightly bound to the Warren class? (ie. destroying a warren, destroys the rabbit array?)