Пример #1
0
        /// <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();
        }
Пример #2
0
        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();
        }
Пример #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);
 }
Пример #4
0
 /// <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));
 }
Пример #5
0
 /// <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);
 }