public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

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

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

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

            case 3:
                newAnimal = new Crocodile();
                break;
            }

            return(newAnimal);
        }
        //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 Koala();
                    break;
                case 1:
                    newAnimal = new Kangaroo();
                    break;
                case 2:
                    newAnimal = new Crocodile();
                    break;
                case 3:
                    newAnimal = new Wombat();
                    break;
            }

            //Return
            return newAnimal;
        }
        public Animal CreateAnimal(int AnimalCode)
        {
            Animal animal = null;

            switch (AnimalCode)
            {
                case 0:
                    animal = new Koala();
                    break;
                case 1:
                    animal = new Crocodile();
                    break;
                case 2:
                    animal = new Kangaroo();
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return animal;
        }
Example #4
0
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

            switch (animalCode)
            {
                case 0:
                    newAnimal = new Crocodile();
                    break;
                case 1:
                    newAnimal = new Kangaroo();
                    break;
                case 2:
                    newAnimal = new Koala();
                    break;
                case 3:
                    newAnimal = new BrownSnake();
                    break;
            }
            return newAnimal;
        }
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

            switch (animalCode)
            {
                case 0:
                    newAnimal = new Kangaroo();
                    break;
                case 1:
                    newAnimal = new FrilledNeckLizard();
                    break;
                case 2:
                    newAnimal = new Wombat();
                    break;
                case 3:
                    newAnimal = new Crocodile();
                    break;
            }

            return newAnimal;
        }
Example #6
0
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

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

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

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

            case 3:
                newAnimal = new BrownSnake();
                break;
            }
            return(newAnimal);
        }