Пример #1
0
 //This method is just to print out the information to the console so that we can verify what was entered was processed correctly
 public virtual void BirdStatement(Birds birds)
 {
     if (Flies)
     {
         Console.WriteLine($"So it looks like your bird is {Color}, it flies, and it eats {Diet}.");
     }
     else
     {
         Console.WriteLine($"So it looks like your bird is {Color}, it does not fly, and it eats {Diet}.");
     }
 }
Пример #2
0
        //This is the original text of the program I ended up shifting over to this method. I think our virtual pet project could become easier if we moved certain sections of code into classes.
        public virtual void BirdQuiz(Birds birds)
        {
            Console.WriteLine("What color is your bird?");
            birds.Color = Console.ReadLine().ToLower();
            Console.WriteLine("Can your bird fly?");
            string flightResponse = Console.ReadLine().ToLower();

            if (flightResponse.Equals("no") || flightResponse.Equals("n"))
            {
                birds.Flies = false;
            }
            else
            {
                birds.Flies = true;
            }
            Console.WriteLine("What does your bird eat?");
            birds.Diet = Console.ReadLine().ToLower();
        }
Пример #3
0
        //I copied the questions from the Birds class version of this method. I commented out the code about flying since that has been set to true, and I asked a question about the speed.
        public override void BirdQuiz(Birds birds)
        {
            Console.WriteLine("What color is your bird?");
            birds.Color = Console.ReadLine().ToLower();
            //Console.WriteLine("Can your bird fly?");
            //string flightResponse = Console.ReadLine().ToLower();
            //if (flightResponse.Equals("no") || flightResponse.Equals("n"))
            //{
            //    raptors.Flies = false;
            //}
            //else
            //{
            //    raptors.Flies = true;
            //}
            Console.WriteLine("What does your bird eat?");
            birds.Diet = Console.ReadLine().ToLower();

            Raptors raptors = birds as Raptors;

            Console.WriteLine("How fast is your bird?");
            raptors.Speed = Console.ReadLine().ToLower();
        }
Пример #4
0
        static void Main(string[] args)
        {
            //This establishes variables of both the Birds and Raptors types so that we have something to work on.
            Birds   birds   = new Birds();
            Raptors raptors = new Raptors();

            //This asks the user whether or not the bird is a raptor. The answer determines which class will be mostly executed for this program.
            Console.WriteLine("Is your bird a raptor?");
            string isRaptor = Console.ReadLine().ToLower();

            if (isRaptor == "no" || isRaptor == "n")
            {
                birds.BirdQuiz(birds);
                birds.BirdStatement(birds);
            }
            if (isRaptor == "yes" || isRaptor == "y")
            {
                raptors.BirdQuiz(raptors);
                raptors.BirdStatement(raptors);
            }


            //Below is the code I had initially written to ask questions about a users bird. I just copy and pasted this code into the Birds class under the "Bird Quiz" method.

            //Console.WriteLine("What color is your bird?");
            //birds.Color = Console.ReadLine().ToLower();
            //Console.WriteLine("Can your bird fly?");
            //string flightResponse = Console.ReadLine().ToLower();
            //if (flightResponse.Equals("no") || flightResponse.Equals("n"))
            //{
            //    birds.Flies = false;
            //}
            //else
            //{
            //    birds.Flies = true;
            //}
            //Console.WriteLine("What does your bird eat?");
            //birds.Diet = Console.ReadLine().ToLower();
        }
Пример #5
0
 //This version of the BirdStatement method incorporates all of the properties of the Raptors class.
 public override void BirdStatement(Birds birds)
 {
     Console.WriteLine("O rly?");
     Console.WriteLine($"So it looks like your bird is {Color}, it flies, it eats {Diet}, and it is {Speed}.");
 }