Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add a thirst feature to Animal, as well as an appropriately named getter & modifier. Make sure all 5 classes still compile & run just

Add a thirst feature to Animal, as well as an appropriately named getter & modifier. Make sure all 5 classes still compile & run just fine. You'll need to change the Animal class, as well as the constructors for all 5 animal classes. Make sure all 5 animal types can report their thirst and drink. Place these new function calls under the existing Speak() calls in main (report, drink, report.)
Create a second main file that uses command line arguments to facilitate generating any number and variety of animals. It should accept two CLAs:
number_of_animals will control a loop that prompts the user for what type of animal they wish to be created (you have 5 possible types.)
file_name is the name of the file that contains a list of animals to be created and their default constructor values.
For the file given, it should behave as such:
g++ main_2.cpp Animal.cpp -o prog && ./prog 8 animals.txt
Woof!
20
40
Woof!
30
50
Meow!
10
10
Sss!
30
50
Squeak!
5
5
Woof!
60
70
Chirp!
40
60
Woof!
75
75
Notes:
Animal** is how you can create the array to store the animals in step 4. i.e. Animal** arr = new Animal*[5]; creates an array that stores 5 animal pointers. Use the new keyword to instantiate each animal during run-time!
You can also use s

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions