/// <summary>
        /// Matches all mature, non-mutant, male and female rabbits, and creates all children
        /// </summary>
        private void procreate()
        {
            foreach (Rabbit firstParent in this.Rabbits)
            {
                if (firstParent.isMale() && firstParent.isMature() && !firstParent.IsRadioactiveMutantVampireBunny)
                {
                    foreach (Rabbit secondParent in this.Rabbits)
                    {
                        if (secondParent.isFemale() && secondParent.isMature() && !secondParent.IsRadioactiveMutantVampireBunny)
                        {
                            Rabbit child = this.giveBirth(secondParent);
                            moveNewbornRabbit(child);
                        }
                    }
                }
            }

            this.moveRabbits();
        }
        public Hill(int numOfMales, int numOfFemales)
        {
            this.Rabbits         = new List <Rabbit>();
            this._deadRabbits    = new List <Rabbit>();
            this._bornRabbits    = new List <Rabbit>();
            this._mutantRabbits  = new List <Rabbit>();
            this._regularRabbits = new List <Rabbit>();

            for (int males = 0; males < numOfMales; males++)
            {
                Rabbit newRabbit = new Rabbit(Sex.Male);
                this.Rabbits.Add(newRabbit);
                this._bornRabbits.Add(newRabbit);
            }

            for (int females = 0; females < numOfFemales; females++)
            {
                Rabbit newRabbit = new Rabbit(Sex.Female);
                this.Rabbits.Add(newRabbit);
                this._bornRabbits.Add(newRabbit);
            }

            this.printStatistics();
        }
Exemple #3
0
 /// <summary>
 /// Adds a rabbit to the given hill
 /// </summary>
 /// <param name="hill"> A hill </param>
 /// <param name="rabbit"> A rabbit </param>
 private static void addRabbit(Hill hill, Rabbit rabbit)
 {
     hill.Rabbits.Add(rabbit);
 }
 /// <summary>
 /// Creates a child based on it's mother
 /// </summary>
 /// <param name="mother"> A mother rabbit</param>
 /// <returns> A child rabbit </returns>
 private Rabbit giveBirth(Rabbit mother)
 {
     return(new Rabbit(mother.Color));
 }
 /// <summary>
 /// Moves the child rabbit to the born and living list
 /// </summary>
 /// <param name="child"> A child rabbit </param>
 private void moveNewbornRabbit(Rabbit child)
 {
     this._bornRabbits.Add(child);
 }