Here is code in cpp:
#include <iostream>
#include <iomanip>
using namespace std;
class Animal
{
private:
string name;
int birthYear;
float weight;
char gender;
public:
Animal(string n, int b, float w, char g)
{
name = n;
birthYear = b;
weight = w;
gender = g;
}
void
printData()
{
cout << "Name : " << name << endl;
cout << "Birth year : " << birthYear << endl;
cout << "Weight : " << weight << endl;
cout << "gender : " << gender << endl;
cout << endl;
}
};
// Driver function
int
main()
{
Animal a1("cow", 2012, 1000.5, 'f');
Animal a2("pig", 2009, 550.5, 'm');
Animal a3("donkey", 1999, 773.42, 'm');
Animal a4("sheep", 2016, 164.23, 'f');
Animal a5("goose", 2004, 10.75, 'f');
a1.printData();
a2.printData();
a3.printData();
a4.printData();
a5.printData();
}
Output:
Animal classes and create instances of them. In the main method do the following: Create a Farm of size 10 Create 5 Animal Objects with the details specified in the table below Add the 5 Animal objec...