コード例 #1
0
ファイル: AnimalMaker.cs プロジェクト: ann-marieb/cs2018
        /// <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
ファイル: Falcon.cs プロジェクト: ann-marieb/cs2018
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="other"> Falcon to be copied.</param>
 public Falcon(Falcon other) : base(other)
 {
     this.flyingSpeed = other.flyingSpeed;
 }