Ejemplo n.º 1
0
        public static Animal CreateAnimal(string animalCategory, string animalName,int shoutNumber)
        {
            Animal result=null;
            switch (animalCategory)
            {
                case "猫":
                    result = new Cat(animalName);
                    break;
                case "狗":
                    result = new Dog(animalName);
                    break;
                case "羊":
                    result = new Sheep(animalName);
                    break;
            }
            result.ShoutNum = shoutNumber;

            return result;
        }
Ejemplo n.º 2
0
        public static Animal CreateAnimal(string animalCategory, string animalName, int shoutNumber)
        {
            Animal result = null;

            switch (animalCategory)
            {
            case "猫":
                result = new Cat(animalName);
                break;

            case "狗":
                result = new Dog(animalName);
                break;

            case "羊":
                result = new Sheep(animalName);
                break;
            }
            result.ShoutNum = shoutNumber;

            return(result);
        }