Exemple #1
0
        static void Main(string[] args)
        {
            //var rabbit = new Rabbit()
            //{
            //    RabbitName = "The General",
            //    RabbitAge = 10
            //};

            int rabbitNumber = 1;

            var rabbit = new Rabbit(rabbitNumber, "Rabbit " + rabbitNumber, 0);

            addRabbit(rabbit);
            rabbitNumber++;

            while (rabbitNumber < 1000)
            {
                using (var db = new RabbitDbContext())
                {
                    RabbitList = db.Rabbits.ToList();
                }

                //Updating age by 1
                foreach (Rabbit r in RabbitList)
                {
                    updateAge(r);
                }

                //Every Rabbit makes another
                foreach (Rabbit r in RabbitList)
                {
                    if (r.RabbitAge > 3)
                    {
                        var rabbitBaby = new Rabbit(rabbitNumber, "Rabbit " + rabbitNumber, 0);
                        addRabbit(rabbitBaby);
                        rabbitNumber++;
                    }
                    if (r.RabbitAge >= 12)
                    {
                        deleteRabbit(r);
                    }
                }
            }
            printRabbits();
        }