Ejemplo n.º 1
0
 private void btnMate_Click(object sender, EventArgs e)
 {
     if (siOne > -1 && siTwo > -1 && siOne != siTwo)
     {
         Creature offspring = new Creature(creatureList[siOne], creatureList[siTwo]);
         society.AdvanceAge(1);
         society.AddCreature(offspring);
         RefreshCreatureList();
         SortCreatureList("Youngest");
         RefreshPopulation();
     }
     siOne = siTwo = -1;
     UpdateMateSelected();
 }
Ejemplo n.º 2
0
        public void TestAdvanceAgeDeathAndGraveyard()
        {
            Creature        cOne           = new Creature();
            Creature        cTWo           = new Creature();
            Creature        cThree         = new Creature();
            Creature        cFour          = new Creature();
            Creature        cFive          = new Creature();
            string          NAME           = "Balzeria";
            string          CLASSIFICATION = "Republic";
            List <Creature> CREATURES      = new List <Creature>()
            {
                cOne, cTWo, cThree, cFour, cFive
            };
            Society         society       = new Society(NAME, CLASSIFICATION, CREATURES);
            List <Creature> creaturesList = new List <Creature>();

            society.AdvanceAge(650); // 650 is the maximum age possible.
            List <string> graveyard = new List <string>();

            Assert.IsTrue(society.GetGraveyard(out graveyard));
            Assert.IsTrue(society.GetCreatures(out creaturesList));
            /// If all creatures in the society die, 4 new random creatures should be populated
            Assert.AreEqual(4, creaturesList.Count);
            Assert.AreEqual(5, graveyard.Count);
            string DeathStringConfirmation = String.Format("{0}, Died at {1} years of age. Generation: {2}. Parents: {3} and {4}",
                                                           cOne.Name,
                                                           cOne.GetMaxAge(),
                                                           cOne.Generation,
                                                           cOne.ParentOne,
                                                           cOne.ParentTwo);

            CollectionAssert.Contains(graveyard, DeathStringConfirmation);
        }