private void Button01_Click(object sender, RoutedEventArgs e)
        {
            counter++;  // starts at zero so first click means first rabbit is 1
            var r = new Rabbit(counter);

            rabbits.Add(r);
            // display rabbits but first clear display
            ListBox01.Items.Clear();
            foreach (var rabbit in rabbits)
            {
                rabbit.Age++;
                ListBox01.Items.Add($"{rabbit.Name,-20} has age {rabbit.Age}");
            }
        }
Esempio n. 2
0
        private void Button01_Click(object sender, RoutedEventArgs e)
        {
            i++; //starts at 0 so first click means first rabbit is 1


            Console.WriteLine("Loop" + i);
            var newRabbit = new Rabbit(i);

            rabbits.Add(newRabbit);
            ListBox01.Items.Clear();
            foreach (Rabbit rab in rabbits)
            {
                rab.Age++;
                if (rab.Age == 60)
                {
                    rab.Name = rab.Name + " is an old geezer, and";
                }
                ListBox01.Items.Add($"{rab.Name,-20} has an age of {rab.Age}");
            }
        }
Esempio n. 3
0
        private void Button01_Click(object sender, RoutedEventArgs e)
        {
            counter++;
            var r = new Rabbit(counter);

            rabbits.Add(r);
            //display rabbits
            ListBox03.Items.Clear();

            foreach (var rabbit in rabbits)
            {
                rabbit.age++;

                ListBox03.Items.Add($"{rabbit.Name} is {rabbit.age} years old");
            }

            //for (int i = 1; i < 100; i++)
            //{
            //    Console.WriteLine("Loop" + i);

            //    foreach (Rabbit r in rabbits)
            //    {

            //        r.age++;
            //        Console.WriteLine($"ages are :{r.Name} is {r.age}");
            //    }

            //    System.Threading.Thread.Sleep(200);



            //    var rabbit = new Rabbit(i);
            //    rabbits.Add(rabbit);
            //    //Rabbit is the CLASS(blueprint)
            //    //rabbit is the actual real rabbit

            //}
        }