c++ Declare an Animal class that has the attributes of Name, Genus, and Weight. Declare four (4) specific animal classes that inherit attributes from the Animal class. In the lab we built two, Duck and Butterfly. Implement show() and speak() methods for each subclass. These methods will also be virtual classes in Animal and will allow the use of an array of Animal* in the main(). Your program should ask the user for the number of animals they would like in there zoo. Allow the user to select each animal from the animal subclasses you have implemented. Store the selections in an array of Animal*. After the user has selected all the animals, step thru the array and have each animal show() and speak() in a sort of parade of selected animals. I'm having a problem with the error message and why it won't display to ascii art and have the user input --- This is my code so far --- /* * File: Zoo.cpp * Author: * Course: CS I * Assignment: What's In Your Zoo? * Due date: 11/10/21 * * This program allows the user for the number of animals they would like in there zoo. Allow the user to select each animal from the animal subclasses that's implemented. * C++ */ #include using namespace std; class Animal { string name; string genus; double weight; public: Animal(string n, string g, double w) { name = n; genus = g; weight = w; } string to_string() { string str; str = "Name: " + name + "\nGenus: " + genus + "\nWeight: " + std::to_string(weight) + "grams\n"; return str; } virtualvoid show();//virtual - if it doesn't have a specific method or previous (allows it to take many different forms) virtualvoid speak(); }; class Duck : public Animal { public: Duck(string n, string g, double w) : Animal(n,g,w){} void show() { cout << " .. \n" << endl; cout << " ( '`< \n" << endl; cout << " )( \n" << endl; cout << " ( ----' '. \n" << endl; cout << " ( ; \n" << endl; cout << " (________,' \n" << endl; cout << "~^~^~^~^~^~^~^~^~^~^~ \n" << endl; cout << " \n" << endl; } void speak() { cout << " Quack! Quack!\n"; } }; class Fox: public Animal { public: Fox(string n, string g, double w) : Animal(n, g, w){} //Fox void show() //output image { cout << " /|_/| \n" << endl; cout << " / ^ ^(_o \n" << endl; cout << " / __.'' \n" << endl; cout << " / \\ \n" << endl; cout << " (_) (_) '._ \n" << endl; cout << " '.__ '. .-''-'. \n" << endl; cout << " ( '. ('.____.'' \n" << endl; cout << " _) )'_, ) \n" << endl; cout << " (__/ (__/ \n" << endl; } void speak() { cout << " ow-wow-wow-wow-wow! \n"; } }; class Parakeet: public Animal { public: Parakeet(string n, string g, double w) : Animal(n, g, w){} void show() //output image { cout << " \\ \n"; cout << " \\ (o> \n"; cout << " (o> //) \n"; cout << " _(()_____V_/_____ \n"; cout << " || || \n"; cout << " || \n"; } void speak() //output voice (txt) { cout << "Chirp, Chirp!\n"; } }; class Koala: public Animal { public: Koala(string n, string g, double w) : Animal(n, g, w){} void show() { cout << " (\\-'''-/) \n" << endl; cout << " | | \n" << endl; cout << " \\ ^ ^ / .-. \n" << endl; cout << " \\_o_/ / / \n" << endl; cout << " /` `\\// | \n" << endl; cout << " / \\ | \n" << endl; cout << " \\ ( ) / | \n" << endl; cout << " /\\_) (_/ \\ / \n" << endl; cout << "| (\\-/) | \n" << endl; cout << "\\ --^o^-- / \n" << endl; cout << " \\ '.___.' / \n" << endl; cout << " .' \\-=-/ '. \n" << endl; cout <<" / /` `\\ \\ \n" << endl; cout <<"(//./ \\.\\) \n" << endl; cout << "`'` `'` \n" << endl; } }; int main() { Animal* zoo[4]; zoo[0] = new Duck("Duck", "Anas", 900.0); zoo[0] -> to_string(); zoo[0] -> show(); zoo[0] -> speak(); for(int i=0; i<4; i++) { delete zoo[i]; } return 0; //int selection; /* Animal animal; cout << animal.to_string(); Duck.show; Duck.speak; return 0; */ }

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
100%

c++ 

Declare an Animal class that has the attributes of Name, Genus, and Weight.  Declare four (4) specific animal classes that inherit attributes from the Animal class.  In the lab we built two, Duck and Butterfly.  Implement show() and speak() methods for each subclass.  These methods will also be virtual classes in Animal and will allow the use of an array of Animal* in the main().

Your program should ask the user for the number of animals they would like in there zoo.  Allow the user to select each animal from the animal subclasses you have implemented.  Store the selections in an array of Animal*.  After the user has selected all the animals, step thru the array and have each animal show() and speak() in a sort of parade of selected animals.

I'm having a problem with the error message and why it won't display to ascii art and have the user input

--- This is my code so far ---

/*
* File: Zoo.cpp
* Author: 
* Course: CS I
* Assignment: What's In Your Zoo?
  • * Due date: 11/10/21
*
* This program allows the user for the number of animals they would like in there zoo. Allow the user to select each animal from the animal subclasses that's implemented.
* C++
*/

#include <iostream>
using namespace std;

class Animal
{
string name;
string genus;
double weight;

public:
Animal(string n, string g, double w)
{
name = n;
genus = g;
weight = w;
}

string to_string()
{
string str;
str = "Name: " + name + "\nGenus: " + genus + "\nWeight: " + std::to_string(weight) + "grams\n";
return str;
}
virtualvoid show();//virtual - if it doesn't have a specific method or previous (allows it to take many different forms)
virtualvoid speak();
};

class Duck : public Animal
{
public:
Duck(string n, string g, double w) : Animal(n,g,w){}

void show()
{
cout << " .. \n" << endl;
cout << " ( '`< \n" << endl;
cout << " )( \n" << endl;
cout << " ( ----' '. \n" << endl;
cout << " ( ; \n" << endl;
cout << " (________,' \n" << endl;
cout << "~^~^~^~^~^~^~^~^~^~^~ \n" << endl;
cout << " \n" << endl;
}
void speak()
{
cout << " Quack! Quack!\n";
}

};

class Fox: public Animal
{
public:
Fox(string n, string g, double w) : Animal(n, g, w){}
//Fox

void show() //output image
{
cout << " /|_/| \n" << endl;
cout << " / ^ ^(_o \n" << endl;
cout << " / __.'' \n" << endl;
cout << " / \\ \n" << endl;
cout << " (_) (_) '._ \n" << endl;
cout << " '.__ '. .-''-'. \n" << endl;
cout << " ( '. ('.____.'' \n" << endl;
cout << " _) )'_, ) \n" << endl;
cout << " (__/ (__/ \n" << endl;
}
void speak()
{
cout << " ow-wow-wow-wow-wow! \n";
}

};
class Parakeet: public Animal
{
public:
Parakeet(string n, string g, double w) : Animal(n, g, w){}
void show() //output image
{
cout << " \\ \n";
cout << " \\ (o> \n";
cout << " (o> //) \n";
cout << " _(()_____V_/_____ \n";
cout << " || || \n";
cout << " || \n";
}
void speak() //output voice (txt)
{
cout << "Chirp, Chirp!\n";
}

};

class Koala: public Animal
{
public:
Koala(string n, string g, double w) : Animal(n, g, w){}
void show()
{
cout << " (\\-'''-/) \n" << endl;
cout << " | | \n" << endl;
cout << " \\ ^ ^ / .-. \n" << endl;
cout << " \\_o_/ / / \n" << endl;
cout << " /` `\\// | \n" << endl;
cout << " / \\ | \n" << endl;
cout << " \\ ( ) / | \n" << endl;
cout << " /\\_) (_/ \\ / \n" << endl;
cout << "| (\\-/) | \n" << endl;
cout << "\\ --^o^-- / \n" << endl;
cout << " \\ '.___.' / \n" << endl;
cout << " .' \\-=-/ '. \n" << endl;
cout <<" / /` `\\ \\ \n" << endl;
cout <<"(//./ \\.\\) \n" << endl;
cout << "`'` `'` \n" << endl;
}
};

int main()
{
Animal* zoo[4];
zoo[0] = new Duck("Duck", "Anas", 900.0);

zoo[0] -> to_string();
zoo[0] -> show();
zoo[0] -> speak();

  for(int i=0; i<4; i++) {
    delete zoo[i];
  }

return 0;

//int selection;
/*
Animal animal;
cout << animal.to_string();
Duck.show;
Duck.speak;
return 0;
*/
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 5 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