Пример #1
0
            public AnimalHierarchy.Animal createAnimal(Random rGen)
            {
                AnimalHierarchy.Animal animal = null;

                switch (rGen.Next(MAX_ANIMALS.NORTH_AMERICA))
                {
                case 0:
                    animal = new AnimalHierarchy.Bison();
                    break;

                case 1:
                    animal = new AnimalHierarchy.Eagle();
                    break;

                case 2:
                    animal = new AnimalHierarchy.Platypus();
                    break;

                case 3:
                    animal = new AnimalHierarchy.Wolf();
                    break;
                }

                return(animal);
            }
Пример #2
0
            public AnimalHierarchy.Animal createAnimal(Random rGen)
            {
                AnimalHierarchy.Animal animal = null;

                switch (rGen.Next(MAX_ANIMALS.AUSTALIA))
                {
                case 0:
                    animal = new AnimalHierarchy.Kangaroo();
                    break;

                case 1:
                    animal = new AnimalHierarchy.Crocodile();
                    break;

                case 2:
                    animal = new AnimalHierarchy.Koala();
                    break;

                case 3:
                    animal = new AnimalHierarchy.Snake();
                    break;
                }

                return(animal);
            }
Пример #3
0
 public void draw()
 {
     for (int i = 0; i < MAX_DISPLAY_ANIMALS; i++)
     {
         // Create an animal based on contenint
         AnimalHierarchy.Animal animal = animalFactory.createAnimal(rGen);
         // Add to listbox
         listBox.Items.Add(animal.ToString());
         // Draw its image vertically
         canvas.DrawImage(animal.Image, X, Y + (HEIGHT * i), WIDTH, HEIGHT);
     }
 }
Пример #4
0
            public AnimalHierarchy.Animal createAnimal(Random rGen)
            {
                AnimalHierarchy.Animal animal = null;

                switch (rGen.Next(MAX_ANIMALS.AFRICA))
                {
                case 0:
                    animal = new AnimalHierarchy.Elephant();
                    break;
                }

                return(animal);
            }