Exemplo n.º 1
0
        public Zoo()
        {
            zoo.Add(giraffes);
            zoo.Add(wolfs);
            zoo.Add(bears);
            Animal wolf1 = new Wolf("Волк", 100);

            wolfs.Add(wolf1);
            Animal bear1 = new Bear("Медведь", 300);

            bears.Add(bear1);
            Animal giraffe1 = new Giraffe("Жираф", 900);

            giraffes.Add(giraffe1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The button used to adopt an animal.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void adoptAnimalButton_Click(object sender, RoutedEventArgs e)
        {
            // Gets the guest from the list box.
            Guest guest = (Guest)this.guestListBox.SelectedItem;

            // Gets the animal from the list box.
            Animal animal = (Animal)this.animalListBox.SelectedItem;

            // Set the animal to guest's adopted animal.
            guest.AdoptedAnimal = animal;

            // Find the animals cage.
            Cage animalCage = zoo.FindCage(animal.GetType());

            // Add the guest to the cage.
            animalCage.Add(guest);

            // Load the guest into the list box.
            this.PopulateGuestListBox();
        }