Пример #1
0
        private void SayName_Button_Click(object sender, RoutedEventArgs e)
        {
            // Define a new List of dogs
            List <Dog> dogs = new List <Dog>();

            // Instantiate some dog objects
            Dog dog1 = new Dog("Muppet", 20, "Rolf");
            Dog dog2 = new Dog("Golden Retriever", 30, "Air Bud");

            // Add the dogs to the list
            dogs.Add(dog1);
            dogs.Add(dog2);

            // Loop through the list and call a method on the objects
            foreach (Dog d in dogs)
            {
                d.SayName();
            }

            Duck duck1 = new Duck(25, "Harry");
            Duck duck2 = new Duck(45, "Henrietta");

            List <Duck> ducks = new List <Duck>();

            ducks.Add(duck1);
            ducks.Add(duck2);

            Kangaroo kangaroo1 = new Kangaroo(45000, "Perry", 300000000);
            Kangaroo kangaroo2 = new Kangaroo(3500, "Terry", 4000026);

            List <Kangaroo> kangaroo = new List <Kangaroo>();

            kangaroo.Add(kangaroo1);
            kangaroo.Add(kangaroo2);
        }
Пример #2
0
        //private void Quack_Button_Click(object sender, RoutedEventArgs e)
        //{
        //    Duck duck = new Duck();
        //    duck.Quack();
        //}

        //private void Ribbit_Button_Click(object sender, RoutedEventArgs e)
        //{
        //    Frog frog = new Frog();
        //    frog.Ribbit();
        //}

        private void Box_Button_Click(object sender, RoutedEventArgs e)
        {
            Random   rand   = new Random();
            int      pounds = rand.Next(1, 300);
            Kangaroo roo    = new Kangaroo(pounds);

            roo.Box();
        }