Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I just need to finish the good code, I already know the details and just want to see the code, please! A class clled 'Anima
I just need to finish the good code, I already know the details and just want to see the code, please!
A class clled 'Anima" exists that hasthree data members: a string called name, a char to represent its type ('i' for invertebrate, f for fish, 'a' for amphibian, 'r' for reptile, 'm for mammal, or b' for bird), and an int to represent a unique ID. The constructor of the class is passed a string and a char and uses them to set the two relating data members. The ID is set automatically using another static data member (not listed above). The class also has one member function: getDetails0 which returns an appropriately formatted string containing the values of all data members 1. Write the code to declare the class called Animal as described above. Also write the constructor and getDetails() functions. [10 marks] 2. Write a C++ class called "Invertebrate" that inherits from the class called "Animal" detailed above. The new Invertebrate class should add another integer data member called numberOfLegs. Write a constructor for the Invertebrate class that sets the value f numberOfLegs to a value that is passed to the constructor. This constructor should utilise the constructor that already exists for the Animal class. Also write a new display function called getDetails) that returns a string (similar to the one for the Animal class), but also includes the extra data member numberOfLegs. [10 marks] Write C++ code to declare an array called animalList to hold Animal pointers, as well as an integer that will keep track of the number of object pointers in the array. Create 5 Animal objects and 5 Invertebrate objects and add them to the array, keeping the counter updated. Display a report of the Animals stored in the array, ensuring that the correct getDetails0 method runs for each item in the array. [10 marks] 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started