예제 #1
0
        /// <summary>
        /// Create animal
        /// </summary>
        /// <param name="name"></param>
        /// <param name="ageInt"></param>
        /// <param name="gender"></param>
        /// <param name="species"></param>
        /// <param name="text1"></param>
        /// <param name="text2"></param>
        /// <returns>animal</returns>
        internal static IAnimal MakeAnimal(string name, int ageInt, string gender, string species, string text1, string text2)
        {
            IAnimal animalObj; //declare animal

            switch (species)
            {
            case "dog":
            {
                animalObj = new Dog(name, ageInt, gender, text1, text2);
            }
            break;

            case "cat":
            {
                animalObj = new Cat(name, ageInt, gender, text1, text2);
            }
            break;

            case "parrot":
            {
                animalObj = new Parrot(name, ageInt, gender, text1, text2);
            }
            break;

            case "falcon":
            {
                animalObj = new Falcon(name, ageInt, gender, text1, text2);
            }
            break;

            default:
                throw new NotImplementedException();
            }
            return(animalObj);
        }
예제 #2
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="other">Copied parrot</param>
 public Parrot(Parrot other) : base(other)
 {
     this.colour = other.colour;
 }