private void SayName_Button_Click(object sender, RoutedEventArgs e)
        {
            List <animal> animals = new List <animal>();
            // 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
            animals.Add(dog1);
            animals.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>();
            animals.Add(duck1);
            animals.Add(duck2);

            foreach (animal animal in animals)
            {
                animal.SayName();
                MessageBox.Show("The height is " + animal.Height);
            }
            Frog        frog1 = new Frog("No", "Bo");
            Frog        frog2 = new Frog("Yes", "Spiky");
            List <Frog> frogs = new List <Frog>();

            frogs.Add(frog1);
            frogs.Add(frog2);
            foreach (Frog frog in frogs)
            {
                frog.SayName();
            }
        }
Exemple #2
0
        public MainWindow()
        {
            InitializeComponent();
            Speakers = new ObservableCollection <Ispeaker>();

            // Define some animals
            Frog frog = new Frog(4, "Kermit", false);
            Dog  dog  = new Dog("Muppet", 20, "Rolf");
            Duck duck = new Duck(9, "Donald");

            // Add the animals to the list
            Speakers.Add(frog);
            Speakers.Add(dog);
            Speakers.Add(duck);

            Robot robot = new Robot("Mike", 2555);

            Speakers.Add(robot);

            lvSpeakers.ItemsSource = Speakers;
        }
Exemple #3
0
        public MainWindow()
        {
            InitializeComponent();
            Animals = new ObservableCollection <Animal>();

            Frog frog = new Frog(4, "Kermit", false, 3);
            Dog  dog  = new Dog("Muppet", 20, "Rolf", 50);
            Duck duck = new Duck(9, "Donald", 30);

            Dog  dogC  = new Dog("Muppet", 200, "Clifford", 1000);
            Duck duckD = new Duck(5, "Daffy", 60);
            Frog frogJ = new Frog(3, "Jeremiah", false, 15);

            Animals.Add(frog);
            Animals.Add(dog);
            Animals.Add(duck);
            Animals.Add(dogC);
            Animals.Add(duckD);
            Animals.Add(frogJ);

            lvAnimals.ItemsSource = Animals;
        }
Exemple #4
0
        private void SayName_Button_Click(object sender, RoutedEventArgs e)
        {
            List <Animal> animals = new List <Animal>();
            // 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
            animals.Add(dog1);
            animals.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>();
            animals.Add(duck1);
            animals.Add(duck2);

            /*
             * foreach (Duck duck in ducks)
             * {
             *  duck.SayName();
             * }
             */

            Frog frog1 = new Frog(25, "Gary", false);
            Frog frog2 = new Frog(45, "Stan", true);

            //List<Frog> frogs = new List<Frog>();
            animals.Add(frog1);
            animals.Add(frog2);

            /*
             * foreach (Frog frog in frogs)
             * {
             *  frog.SayName();
             * }
             */

            //separation
            WarElephant warElephant1 = new WarElephant(65, "Joe", 5);
            WarElephant warElephant2 = new WarElephant(85, "Zach", 10);

            //List<WarElephant> warElephants = new List<WarElephant>();
            animals.Add(warElephant1);
            animals.Add(warElephant2);

            /*
             * foreach (WarElephant warElephant in warElephants)
             * {
             *  warElephant.SayName();
             * }
             */

            foreach (Animal animal in animals)
            {
                animal.SayName();
            }
        }
Exemple #5
0
        private void Ribbit_Button_Click(object sender, RoutedEventArgs e)
        {
            Frog frog = new Frog();

            frog.Ribbit();
        }
Exemple #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Frog frog = new Frog(3, "Mikey", true);

            frog.Ribbit();
        }
Exemple #7
0
        private void SayName_Button_Click(object sender, RoutedEventArgs e)
        {
            List <Animal> animals = new List <Animal>();
            // 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
            animals.Add(dog1);
            animals.Add(dog2);

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

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

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

            animals.Add(duck1);
            animals.Add(duck2);

            //foreach (Duck d in animals)
            //{
            //    d.SayName();
            //}

            //List<Frog> frogs = new List<Frog>();

            Frog frog1 = new Frog(25, "Croak", true);
            Frog frog2 = new Frog(45, "Pepe", false);

            animals.Add(frog1);
            animals.Add(frog2);

            //foreach (Frog f in animals)
            //{
            //    f.SayName();
            //}


            Cow cow1 = new Cow(25, "Lennard", "brown");
            Cow cow2 = new Cow(45, "Harold", "white");

            animals.Add(cow1);
            animals.Add(cow2);

            //foreach (Cow c in cows)
            //{
            //    c.SayName();
            //}
            foreach (Animal a in animals)
            {
                a.SayName();
                MessageBox.Show("The height is " + a.Height);
            }
        }
        private void SayName_Button_Click(object sender, RoutedEventArgs e)
        {
            List <Animals> animal = new List <Animals>();
            // 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, "Sir Quacks");
            Duck duck2 = new Duck(45, "Quack Sparrow");
            Duck duck3 = new Duck(35, "James Pond");


            //List<Duck> ducks = new List<Duck>();
            animal.Add(duck1);
            animal.Add(duck2);
            animal.Add(duck3);


            foreach (Duck duck in ducks)
            {
                duck.SayName();
            }

            Frog frog1 = new Frog(5, "Kermit");
            Frog frog2 = new Frog(7, "Lollihops");
            Frog frog3 = new Frog(9, "Frogger");

            List <Frog> frogs = new List <Frog>();

            animal.Add(frog1);
            animal.Add(frog2);
            animal.Add(frog3);

            foreach (Frog frog in frogs)
            {
                frog.SayName();
            }

            Snake snake1 = new Snake(1, "Severus Snake");
            Snake snake2 = new Snake(5, "Nope Rope");
            Snake snake3 = new Snake(5, "Nagini");

            List <Snake> snakes = new List <Snake>();

            animal.Add(snake1);
            animal.Add(snake2);
            animal.Add(snake3);

            //foreach (Snake snake in snakes)
            //{
            //    snake.SayName();
            //}
            foreach (Animals animal in animals)
            {
                ;
            }
        }