SET-252 – C Programming #2 Homework: 4 – Polymorphism Step 1 – Parent Class • Create a CAnimal class. • Add the following protected properties: m_strName, m_strType • Add the following public methods: Get/Set Name, Get/Set Type, virtual MakeNoise. Step 2 – Child Classes • Create three or more child classes based on the CAnimal class (e.g. CDog, CCow, CDragon). • Each child class must re-define the MakeNoise method. • Each child class must have at least one unique property (e.g. Breed, Color, AmountOfGold). • Each child class must have at least one unique method (e.g. Fetch, Graze, BreathFire). • Create at least one instance for each child class and call the set methods in each one to populate/initialize them. Step 3 – Polymorphism – Part 1 • Create an array of CAnimal* called paclsZoo of at least size 5. • Populate the zoo with pointers to the child class instances created in the previous step. You’ll need to explicit cast the pointers/addresses. • Set at least one cell in the array to 0/null. Step 4 – Polymorphism – Part 2 • Write a FOR loop that will loop through the zoo and for each non-null cell print the animal name, type and call the MakeNoise method. Make sure that the correct child-specific information is displayed. Step 5 – Polymorphism – Part 3 • Write a FOR loop that will loop through the zoo and for each non-null cell explicitly cast the pointer into the child class specific type and call the unique child class method. You’ll need to string compare the animal type in order to make the correct cast. Can someone please help solve it.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

SET-252 – C Programming #2 Homework: 4 – Polymorphism

Step 1 – Parent Class • Create a CAnimal class. • Add the following protected properties: m_strName, m_strType • Add the following public methods: Get/Set Name, Get/Set Type, virtual MakeNoise.

Step 2 – Child Classes • Create three or more child classes based on the CAnimal class (e.g. CDog, CCow, CDragon). • Each child class must re-define the MakeNoise method. • Each child class must have at least one unique property (e.g. Breed, Color, AmountOfGold). • Each child class must have at least one unique method (e.g. Fetch, Graze, BreathFire). • Create at least one instance for each child class and call the set methods in each one to populate/initialize them.

Step 3 – Polymorphism – Part 1 • Create an array of CAnimal* called paclsZoo of at least size 5. • Populate the zoo with pointers to the child class instances created in the previous step. You’ll need to explicit cast the pointers/addresses. • Set at least one cell in the array to 0/null.

Step 4 – Polymorphism – Part 2 • Write a FOR loop that will loop through the zoo and for each non-null cell print the animal name, type and call the MakeNoise method. Make sure that the correct child-specific information is displayed.

Step 5 – Polymorphism – Part 3 • Write a FOR loop that will loop through the zoo and for each non-null cell explicitly cast the pointer into the child class specific type and call the unique child class method. You’ll need to string compare the animal type in order to make the correct cast.

Can someone please help solve it.  

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY