cat.cpp
#include "cat.h"
cat::cat():pet(){
hairlength = "Normal";
otherCats = false;
}
cat::cat(string sz, string a, char gen, string hair, bool other):pet(sz,a,gen){
hairlength = hair;
otherCats = other;
}
void cat::setHairLength(string hair){
hairlength = hair;
}
string cat::getHairLength(void){
return hairlength;
}
void cat::setOtherCats(bool other){
otherCats = other;
}
bool cat::getOtherCats(void){
return otherCats;
}
void cat::printInfo(void){
pet::printInfo();
cout<<"The cat hairlength is:\t"<
if(otherCats == true){
cout<<"The cat is like other cats"<
}else{
cout<<"The cat is not like other cats"<
}
}
cat.h
#ifndef __CAT_H__
#define __CAT_H__
#include "pet.h"
class cat:public pet{
protected:
string hairlength;
bool otherCats;
public:
cat();
cat(string sz, string a, char gen, string hair, bool other);
void setHairLength(string hair);
string getHairLength(void);
void setOtherCats(bool other);
bool getOtherCats(void);
void printInfo(void);
};
#endif // __CAT_H__
catadoptee.cpp
#include "catadoptee.h"
catadoptee::catadoptee():cat(){
name = "Meow";
personality = "nice";
}
catadoptee::catadoptee(string sz, string a, char gen, string hair, bool other, string nm, string pers):cat(sz,a,gen,hair,other){
name = nm;
personality = pers;
}
void catadoptee::setName(string nm){
name = nm;
}
string catadoptee::getName(void){
return name;
}
void catadoptee::setPersonality(string pers){
personality = pers;
}
string catadoptee::getPersonality(void){
return personality;
}
void catadoptee::printInfo(void){
cat::printInfo();
cout<<"The cat name is:\t"<
cout<<"The cat personality is:\t"<
}
catadoptee.h
#ifndef __CATADOPTEE_H__
#define __CATADOPTEE_H__
#include "cat.h"
class catadoptee:public cat{
protected:
string name;
string personality;
public:
catadoptee();
catadoptee(string sz, string a, char gen, string hair, bool other, string nm, string pers);
void setName(string nm);
string getName(void);
void setPersonality(string pers);
string getPersonality(void);
void printInfo(void);
};
#endif // __CATADOPTEE_H__
dog.cpp
#include "dog.h"
dog::dog():pet(){
breed = "BullDog";
housetrained = true;
}
dog::dog(string sz, string a, char gen, string brd, bool trained):pet(sz,a,gen){
breed = brd;
housetrained = trained;
}
void dog::setBreed(string brd){
breed = brd;
}
string dog::getBreed(void){
return breed;
}
void dog::setTrained(bool Trained){
housetrained = Trained;
}
bool dog::getTrained(void){
return housetrained;
}
void dog::printInfo(void){
pet::printInfo();
cout<<"The breed of the dog is:\t"<
if(housetrained == true){
cout<<"The pet is house trained"<
}else{
cout<<"The pet is not house trained"<
}
}
dog.h
#ifndef __DOG_H__
#define __DOG_H__
#include "pet.h"
class dog:public pet{
protected:
string breed;
bool housetrained;
public:
dog();
dog(string sz, string a, char gen, string brd, bool trained);
void setBreed(string brd);
...