Create a pure virtual base class Animal. Create a C++ project4 Create a pure vir
ID: 3534979 • Letter: C
Question
Create a pure virtual base class Animal.
Create a C++ project4
Create a pure virtual base class Animal.
The base class has one private string attribute: name.
The base class has one constant string method, Name, that returns the class's name attribute.
The Animal class constructor has one string parameter: name. The constructor makes sure that the name is a string that is neither empty nor filled with white-space characters; otherwise it throws an exception.
The base class has three pure virtual Boolean methods: AreYouAMeatEater, DoYouHaveFourLegs and AreYouAMammal. We shall call these methods characteristic methods.
Use the base classà¢ÃƒÆ’ ¢Ãƒ ¢Ã¢â€š ¬Ã… ¡Ãƒâ€šÃ‚ ¬ÃƒÆ’ ¢Ãƒ ¢Ã¢â€š ¬Ã… ¾Ãƒâ€šÃ‚ ¢s Name method to verify an animal's identity.
e.g.
cin.getline(name, ' ');
if(name == animal->Name())
cout << "You are who you say you are!"<< endl;
else
 cout << "You are an imposter, begone!"<< endl;
A derived class has only a default constructor. It invokes the Animal class's one parameter constructor.
The derived classes define the pure virtual base class's virtual methods. The methods should not contain any input or output statements. The following table shows the values that the derived class methods return.
AreYouAMeatEater
DoYouHaveFourLegs
AreYouAMammal
Panther
True
True
True
Komodo Dragon
True
True
False
Sperm Whale
True
False
True
Rattle Snake
True
False
False
Cow
False
True
True
Green Iguana
False
True
False
Manatee
False
False
True
Sparrow
False
False
False
Create an array of eight pointers to Animals. Assign a pointer to a particular Animal to each element of the array. No two pointers may point to the same kind of Animal. In other words all pointers must point to different animals.
Use the array of eight pointers to write the following game.
The game randomly generates a number between zero and seven and uses the number to select an element of the array.
Use the selected animal's characteristic methods to display its characteristics.
From the information that the animal reveals about itself, the user tries to guess the animal's identity. If the user guesses the animal's identity then the player wins; otherwise the player loses. Use the base class's Name method to verify a derived class animal's identity.
Play the game in loop so the user may play the game as many times as he wishes.
Your program's behavior and "project4.exe" behavior should be identical. That is, given the same input as "project4.exe", your program should produce the same output and given the same input as your program, "project4.exe" should produce the same output.
If possible please email to bartboy213@ymail.com
AreYouAMeatEater
DoYouHaveFourLegs
AreYouAMammal
Panther
True
True
True
Komodo Dragon
True
True
False
Sperm Whale
True
False
True
Rattle Snake
True
False
False
Cow
False
True
True
Green Iguana
False
True
False
Manatee
False
False
True
Sparrow
False
False
False
Explanation / Answer
Please rate with 5 stars :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.