//Code for this factories implementation of createAnimal (req'd by the interface)
        public Animal createAnimal(int animalCode)
        {
            //Create an "empty" animal, which will later be loaded with a specific instance of an animal.
            Animal newAnimal = null;

            //Switch to determine which animal type was requested.
            switch (animalCode)
            {
                case 0:
                    newAnimal = new Bison();
                    break;
                case 1:
                    newAnimal = new Eagle();
                    break;
                case 2:
                    newAnimal = new Wolf();
                    break;
                case 3:
                    newAnimal = new Armadillo();
                    break;
            }

            //Return
            return newAnimal;
        }
Ejemplo n.º 2
0
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

            switch (animalCode)
            {
                case 0:
                    newAnimal = new Bison();
                    break;
                case 1:
                    newAnimal = new Wolf();
                    break;
                case 2:
                    newAnimal = new Eagle();
                    break;
                case 3:
                    newAnimal = new Moose();
                    break;
            }
            return newAnimal;
        }
Ejemplo n.º 3
0
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

            switch (animalCode)
            {
            case 0:
                newAnimal = new Bison();
                break;

            case 1:
                newAnimal = new Wolf();
                break;

            case 2:
                newAnimal = new Eagle();
                break;

            case 3:
                newAnimal = new Moose();
                break;
            }
            return(newAnimal);
        }
Ejemplo n.º 4
0
        public Animal CreateAnimal(int AnimalCode)
        {
            Animal animal = null;

            switch (AnimalCode)
            {
                case 0:
                    animal = new Bison();
                    break;
                case 1:
                    animal = new Wolf();
                    break;
                case 2:
                    animal = new Eagle();
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return animal;
        }