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

            switch (animalCode)
            {
                case 0:
                    newAnimal = new Zebra();
                    break;
                case 1:
                    newAnimal = new Lion();
                    break;
                case 2:
                    newAnimal = new Giraffe();
                    break;
                case 3:
                    newAnimal = new Elephant();
                    break;
            }
            return newAnimal;
        }
        public Animal CreateAnimal(int AnimalCode)
        {
            Animal animal = null;

            switch (AnimalCode)
            {
                case 0:
                    animal = new Elephant();
                    break;
                case 1:
                    animal = new Lion();
                    break;
                case 2:
                    animal = new Leopard();
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

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

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

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

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

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