コード例 #1
0
        public Animal createAnimal(int animalCode)
        {
            Animal newAnimal = null;

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

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

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

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

            return(newAnimal);
        }
コード例 #2
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;
        }