Пример #1
0
        public override string ToString()
        {
            string theirGenderPronoun,                  //The gender pronoun to use
                   animalInfo = "";                     //String of info to return

            //Finds out the animal's gender pronoun
            theirGenderPronoun = Gender.ToLower() == "male" ? "He" : "She";

            //Creates the formatted string of the info to return
            animalInfo += string.Format("This is our {0} year old {1}.  ", Age, Type.ToLower());

            animalInfo += string.Format("{0} lives here at {1}.  ", theirGenderPronoun, ZooLocation);

            animalInfo += string.Format("{0} is a {1}.  ", theirGenderPronoun, DietType.ToLower());

            animalInfo += HowTheAnimalMoves;

            return(animalInfo);
        }
Пример #2
0
        /**
         * Prints out all the info on a reptile in a formatted matter.
         * @return The info about a reptile
         */
        public override string ToString()
        {
            string theirGenderPronoun,                  //The gender pronoun to use
                   theirDietType = DietType.ToLower(),  //The reptile's diet type
                   animalInfo    = "";                  //The string to return with the reptile's info

            //Finds out the reptile's gender pronoun
            if (Gender.ToLower() == "male") //Is a male
            {
                theirGenderPronoun = "He";
            }
            else //Is a female
            {
                theirGenderPronoun = "She";
            }

            if (DietType == "omnivore")
            {
                theirDietType = "an " + theirDietType;
            }
            else
            {
                theirDietType = "a " + theirDietType;
            }

            //Creates the formatted string of the info to return
            animalInfo += string.Format("This is our {0} year old {1}.  ",
                                        Age, Type.ToLower());

            animalInfo += string.Format("{0} lives {1} at {2}.  ",
                                        theirGenderPronoun, (LivesIndoors ? "indoors" : "outdoors"), ZooLocation);

            animalInfo += string.Format("{0} is {1}shelled and is {2}.  ",
                                        theirGenderPronoun, (HasAShell ? "" : "not "), theirDietType);

            animalInfo += HowTheAnimalMoves;

            return(animalInfo);
        }
Пример #3
0
        /**
         * Prints out all the info of the mammal in a formatted matter.
         * @return The info of the mammal
         */
        public override string ToString()
        {
            string theirGenderPronoun,
                   animalInfo = "";

            //Finds out the mammal's gender pronoun
            if (Gender.ToLower() == "male") //Is a male
            {
                theirGenderPronoun = "He";
            }
            else //Is a female
            {
                theirGenderPronoun = "She";
            }

            //Creates the formatted string of the info to return
            animalInfo += string.Format("This is one of our {0}s.  ",
                                        Type.ToLower());

            animalInfo += string.Format("{0}\'s {1} years old and weighs {2:N1} pounds.  ",
                                        theirGenderPronoun, Age, Weight);

            animalInfo += string.Format("{0} lives here at {1}, where {2} eats {3} {4} meals per day.  ",
                                        theirGenderPronoun, ZooLocation, theirGenderPronoun.ToLower(), DailyMealCount, DietType.ToLower());

            animalInfo += HowTheAnimalMoves;

            return(animalInfo);
        }