Beispiel #1
0
        public Animal reproduce(string species, string baby_name, GenderType baby_gender)
        {
            Animal child = null;

            switch (species)
            {
            case "Toucan":
                child = new Toucan(baby_name, 0, baby_gender, 10);
                break;

            case "Penguin":
                child = new Penguin(baby_name, 0, baby_gender, 10);
                break;

            case "Pelican":
                child = new Pelican(baby_name, 0, baby_gender, 10);
                break;

            case "Ostrich":
                child = new Ostrich(baby_name, 0, baby_gender, 10);
                break;

            default:
                throw new ArgumentException("Invalid Species.");
            }
            return(child);
        }
Beispiel #2
0
        public Animal AddAnimal(string species, string name, int age, GenderType gender, int health)
        {
            Animal animal = null;

            switch (species)
            {
            case "Toucan":
                animal = new Toucan(name, age, gender, health);
                break;

            case "Ostrich":
                animal = new Ostrich(name, age, gender, health);
                break;

            case "Penguin":
                animal = new Penguin(name, age, gender, health);
                break;

            case "Pelican":
                animal = new Pelican(name, age, gender, health);
                break;

            default:
                throw new ArgumentException("Invalid Species.");
            }
            animals.Add(animal);
            return(animal);
        }