previous assignment code
/*C++ test program to test the classes, Animal, Mammal and Cat
and print the results on console window.*/
//Main.cpp
//include header files
#include<iostream>
//include Animal, Mammal and Cat header files
#include "Animal.h"
#include "Mammal.h"
#include "Cat.h"
using namespace std;
int main()
{
//create Animal object
Animal animal("Dog","Mammal",4);
cout<<"Animal object details"<<endl;
cout<<"Name:
"<<animal.getName()<<endl;
cout<<"Type:
"<<animal.getType()<<endl;
cout<<"# of Legs:
"<<animal.getLegs()<<endl;
cout<<endl<<endl;
//create Cat object
Cat cat("byssinian cat","carnivorous mammal",4,"short
hair",true);
cout<<"Cat object details"<<endl;
cout<<"name:
"<<cat.getName()<<endl;
cout<<"type:
"<<cat.getType()<<endl;
cout<<"hair_type
"<<cat.getHairType()<<endl;
cout<<"domesticated:
"<<cat.getDomestic()<<endl;
cat.eat();
system("pause");
return 0;
}
--------------------------------------------------------------------------------------------------------------
//Animal.h
#ifndef ANIMAL_H
#define ANIMAL_H
#include<iostream>
#include<string>
using namespace std;
class Animal
{
private:
string name;
string type;
int m_legs;
public:
Animal(string,string,int);
void setName(string);
string getName();
void setType(string);
string getType();
void setLegs(int);
int getLegs();
virtual void eat();
};
#endif ANIMAL_H
--------------------------------------------------------------------------------------------------------------
//Animal.cpp
#include<iostream>
#include "Animal.h"
using namespace std;
Animal::Animal(string name ,string type ,int m_legs)
{
this->name=name;
this->type=type;
this->m_legs=m_legs;
}
void Animal::setName(string name)
{
this->name=name;
}
string Animal::getName()
{
return name;
}
void Animal::setType(string)
{
this->type=type;
}
string Animal::getType()
{
return type;
}
void Animal::setLegs(int m_legs)
{
this->m_legs=m_legs;
}
int Animal::getLegs()
{
return m_legs;
}
void Animal::eat()
{
cout<<"Eat food."<<endl;
}
--------------------------------------------------------------------------------------------------------------
//Mammal.h
#ifndef MAMMAL_H
#define MAMMAL_H
#include<iostream>
#include<string>
#include "Animal.h"
using namespace std;
class Mammal : public Animal
{
private:
string name;
string type;
int m_legs;
string hariType;
public:
Mammal(string,string,int, string hairType);
void setHairType(string);
string getHairType();
virtual void eat()=0;
};
#endif MAMMAL_H
--------------------------------------------------------------------------------------------------------------
//Mammal.cpp
#include<iostream>
#include "Mammal.h"
#include "Animal.h"
using namespace std;
Mammal::Mammal(string name ,string type ,int m_legs,
string hairType) :Animal(name,type,m_legs)
{
this->hariType=hairType;
}
void Mammal::setHairType(string hairType)
{
this->hariType=hairType;
}
string Mammal::getHairType()
{
return hariType;
}
void Mammal::eat()
{
cout<<"Eat wide range of
food."<<endl;
}
--------------------------------------------------------------------------------------------------------------
//Cat.h
#ifndef CAT_H
#define CAT_H
#include<iostream>
#include<string>
#include "Mammal.h"
using namespace std;
class Cat : public Mammal
{
private:
string name;
string type;
int m_legs;
bool domesticated;
public:
Cat(string,string,int, string, bool );
void setDemostic(bool);
bool getDomestic();
virtual void eat();
};
#endif CAT_H
--------------------------------------------------------------------------------------------------------------
//Cat.cpp
#include<iostream>
#include "Cat.h"
#include "Mammal.h"
using namespace std;
Cat::Cat(string name,string type, int legs, string hairType,
bool domesticated)
:Mammal(name,type,m_legs,hairType)
{
this->domesticated=domesticated;
}
void Cat::setDemostic(bool hairType)
{
this->domesticated=domesticated;
}
bool Cat::getDomestic()
{
return domesticated;
}
void Cat::eat()
{
cout<<"eat fish."<<endl;
}
Based on your previous assignment code, you will be adding an additional class Owner.
private member variables --
string name;
string address;
//we can have more attributes…but let’s keep things simple
public member methods --
constructors (default, parameterized)
setters and getters
//You many create any additional member method(s) to your design need.
private member variables --
//add the following data member to Cat class
Owner master;
public member methods --
//update or add the following related methods to the class
constructors
setters and getters
Cat orderCat(Owner master); // in this function, you should ask the owner, the input her criteria to choose a pet cat such as name, type, hair_type. The domesticated attribute should be set to true. Then return the Cat object.
Do whatever you feel suitable in testing and illustrating your program, such as create an Owner object and then create a Cat object via orderCat() function.
Required modification has been done in Main.cpp,Cat.h,Cat.cpp,Owner.h,Owner.cpp
Main.cpp
#include<iostream>
#include<cstdlib>
#include "Animal.h"
#include "Mammal.h"
#include "Cat.h"
#include "Owner.h"
using namespace std;
int main()
{
//create Animal object
Animal animal("Dog","Mammal",4);
cout<<"Animal object details"<<endl;
cout<<"Name: "<<animal.getName()<<endl;
cout<<"Type: "<<animal.getType()<<endl;
cout<<"# of Legs: "<<animal.getLegs()<<endl;
cout<<endl<<endl;
//create Cat object
Owner me("Self","NoWhere");
Cat cat("byssinian cat","carnivorous mammal",4,"short
hair",true,me);
cout<<"Cat object details"<<endl;
cout<<"name: "<<cat.getName()<<endl;
cout<<"type: "<<cat.getType()<<endl;
cout<<"hair_type
"<<cat.getHairType()<<endl;
cout<<"domesticated:
"<<cat.getDomestic()<<endl;
cout<<"Owner: ";
Owner owner= cat.getOwner();
cout<<"Name:"<<owner.getName()<<"
Address:"<<owner.getAddress()<<endl;
cat.eat();
system("pause");
return 0;
}
Owner.h
#ifndef OWNER_H
#define OWNER_H
#include<iostream>
#include<string>
#include "Mammal.h"
using namespace std;
class Owner{
private:
string name;
string address;
public:
Owner(string ,string );
void setName(string);
string getName();
void setAddress(string);
string getAddress();
};
#endif OWNER_H
Onwer.cpp
#include<iostream>
#include "Owner.h"
using namespace std;
Owner::Owner(string name, string address)
{
this->name=name;
this->address=address;
}
void Owner::setName(string name)
{
this->name=name;
}
string Owner::getName()
{
return name;
}
void Owner::setAddress(string)
{
this->address=address;
}
string Owner::getAddress()
{
return address;
}
------------------------------------------------------------------------------------------------------------------------------
Cat.h
#ifndef CAT_H
#define CAT_H
#include<iostream>
#include<string>
#include "Mammal.h"
#include "Owner.h"
using namespace std;
class Cat : public Mammal
{
private:
string name;
string type;
int m_legs;
bool domesticated;
Owner& owner;
public:
Cat(string,string,int, string, bool ,Owner& );
void setDemostic(bool);
bool getDomestic();
virtual void eat();
Owner getOwner();
void setOwner(Owner);
};
#endif CAT_H
---------------------------------------------------------------------------------------
cat.cpp
//Cat.cpp
#include<iostream>
#include "Cat.h"
#include "Mammal.h"
using namespace std;
Cat::Cat(string name,string type, int legs, string hairType,
bool domesticated,Owner& o)
:Mammal(name,type,m_legs,hairType),owner(o)
{
this->domesticated=domesticated;
}
void Cat::setDemostic(bool hairType)
{
this->domesticated=domesticated;
}
bool Cat::getDomestic()
{
return domesticated;
}
void Cat::setOwner(Owner owner)
{
this->owner=owner;
}
Owner Cat::getOwner()
{
return owner;
}
void Cat::eat()
{
cout<<"eat fish."<<endl;
}
------------------------------------------------------------------------------------------------
Below files has not been modified
Animal.h
//Animal.h
#ifndef ANIMAL_H
#define ANIMAL_H
#include<iostream>
#include<string>
using namespace std;
class Animal
{
private:
string name;
string type;
int m_legs;
public:
Animal(string,string,int);
void setName(string);
string getName();
void setType(string);
string getType();
void setLegs(int);
int getLegs();
virtual void eat();
};
#endif ANIMAL_H
------------------------------------------------------------------------------------
Mammal.h
//Mammal.h
#ifndef MAMMAL_H
#define MAMMAL_H
#include<iostream>
#include<string>
#include "Animal.h"
using namespace std;
class Mammal : public Animal
{
private:
string name;
string type;
int m_legs;
string hariType;
public:
Mammal(string,string,int, string hairType);
void setHairType(string);
string getHairType();
virtual void eat()=0;
};
#endif MAMMAL_H
--------------------------------------------------------------------------------------
Animal.cpp
//Animal.cpp
#include<iostream>
#include "Animal.h"
using namespace std;
Animal::Animal(string name ,string type ,int m_legs)
{
this->name=name;
this->type=type;
this->m_legs=m_legs;
}
void Animal::setName(string name)
{
this->name=name;
}
string Animal::getName()
{
return name;
}
void Animal::setType(string)
{
this->type=type;
}
string Animal::getType()
{
return type;
}
void Animal::setLegs(int m_legs)
{
this->m_legs=m_legs;
}
int Animal::getLegs()
{
return m_legs;
}
void Animal::eat()
{
cout<<"Eat food."<<endl;
}
-------------------------------------------------------------------------------------------
Mammal.cpp
//Mammal.cpp
#include<iostream>
#include "Mammal.h"
#include "Animal.h"
using namespace std;
Mammal::Mammal(string name ,string type ,int m_legs,
string hairType) :Animal(name,type,m_legs)
{
this->hariType=hairType;
}
void Mammal::setHairType(string hairType)
{
this->hariType=hairType;
}
string Mammal::getHairType()
{
return hariType;
}
void Mammal::eat()
{
cout<<"Eat wide range of food."<<endl;
}
-----------------------------------------------------------------------------------
Also find below screenshot of working code

previous assignment code /*C++ test program to test the classes, Animal, Mammal and Cat and print...
Please submit the following files for this assignment: *****************Animal.h, Animal.cpp, Mammal.h, Mammal.cpp, Cat.h, Cat.cpp, main.cpp********* Assignment 4 – OOP – inheritances Create a base class Animal (Animal.h, Animal.cpp) Member variables (private): string name; string type; Member methods (public): Constructor(s) Setters Getters eat(); //display “Eat food.” Create a derived class Mammal from Animal (public) (Mammal.h, Mammal.cpp) Member variables (private): string hair_type; //eg: fur, hair,etc Member methods (public): Constructor(s) Setters Getters Create a derived class Cat from Mammal (public) (Cat.h, Cat.cpp) Member...
Please submit the following files for this assignment: **************************Animal.h, Animal.cpp, Mammal.h, Mammal.cpp, Cat.h, Cat.cpp, main.cpp******************************************************** Assignment 4 – OOP – inheritances Create a base class Animal (Animal.h, Animal.cpp) Member variables (private): string name; string type; Member methods (public): Constructor(s) Setters Getters eat(); //display “Eat food.” Create a derived class Mammal from Animal (public) (Mammal.h, Mammal.cpp) Member variables (private): string hair_type; //eg: fur, hair,etc Member methods (public): Constructor(s) Setters Getters Create a derived class Cat from Mammal (public) (Cat.h, Cat.cpp) Member...
Given the following code: #include <iostream> #include <iomanip> using namespace std; class Animal{ private: int height; int weight; public: void setHeight(int h){ height = h; } int getHeight(){ return height; } void setWeight(int w){ weight = w; } int getWeight(){ return weight; } virtual void makeSound() = 0; virtual void eat(); }; class Dog: public Animal{ public: void makeSound(){ cout << "Bow Bow\n"; } void eat (){ cout <<"The dog is eating\n"; } void Catch(){ cout << "The dog is...
In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...
In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to make the displayAnimal function anim parameter as an object variable, not a reference variable. Run the code and examine the output. What has changed? Polymorphic behavior is not possible when an object is passed by value. Even though printClassName is declared virtual, static binding still takes place because anim is not a reference variable or a pointer. Alternatively we could have used an Animal...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...
Greetings, everybody I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h) Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class. Here are my files: (1) Main.cpp #include <iostream> #include <string> #include "StudentGrades.h" using namespace std; int...
Ship, CruiseShip, and CargoShip Classes (in C++ language i use visual studios to code with) design a Ship class that has the following members: - A member variable for the name of the ship (a string) - A member variable for the year that the ship was built (a string) - A contsructor and appropriate accessors and mutators - A virtual print function that displays the ship's name and the year it was built (nobody seems to get this part...
10.18 LAB: Plant information (vector) Given a base Plant class and a derived Flower class, complete main() to create a vector called myGarden. The vector should be able to store objects that belong to the Plant class or the Flower class. Create a function called PrintVector(), that uses the PrintInfo() functions defined in the respective classes and prints each element in myGarden. The program should read plants or flowers from input (ending with -1), adding each Plant or Flower to...