Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CIS247 Week 5 Lab The following problem should be created as a project in Visual Studio, compiled and debugged. Be sure to add a header to your code and properly document the code. Copy your code into...

1 answer below »
CIS247 Week 5 La
The following problem should be created as a project in Visual Studio, compiled and debugged. Be sure to add a header to your code and properly document the code. Copy your code into a Word document named with your last name included such as: CIS247_Lab5_Smith. Also include screen prints of your test runs. Submit this Word document and the project file (zipped).
This is a problem using class inheritance and polymorphism. The New Friend pet adoption agency handles only dogs and cats. This is how they keep track of their stock.
We will have the following 5 classes:
Base Class: Pet
Derived from Pet: Cat, Dog
Derived from Dog: DogAdoptee
Derived from Cat : CatAdoptee
Pet
Dog
Cat
DogAdoptee
CatAdoptee
Use these UML diagrams to code your classes; note: the # symbol means Protected access.
    Pet
    #size : string
possible values are small, medium, large
#age : string    
possible values are young, adult, senio
#gender : char
possible values are M or F
    +Pet()
+Pet(sz : string, a : string, gen: char)
setters and getters can be omitted or coded; they are optional
+printInfo() : void    
print pet’s information including size, age and gender (Hint: you will need an if
XXXXXXXXXXstatement to print “male” when gender == ‘M’)
    Dog
    #
eed    : string     
this could be any
eed or mixed
eed
#houseTrained : bool
true or false
    +Dog()
+Dog(sz : string, a : string, gen : char,
d : string, trained : bool)
+setBreed(
d : string) : void
+getBreed() : string
+setTrained(trained : bool) : void
+getTrained() : bool
+printInfo() : void    
print Pet information and information about
eed and whether house trained
    Cat
    #hairLength : string
values can be long, medium or short
#otherCats : bool
true or false on whether it gets along with other cats in the house
    +Cat()
+Cat(sz : string, a : string, gen : char, hair : string, other : bool)
+setHairLength(hair : string) : void
+getHairLength() : string
+setOtherCats(other : bool) : void
+getOtherCats() : bool
+printInfo() : void    
print Pet information along with hair length and whether it gets along with
XXXXXXXXXXother cats
    DogAdoptee
    -name : string
-activityLevel : string
values can be high, medium, low
    DogAdoptee()
DogAdoptee(sz : string, a : string, gen : char,
d : string, trained : bool, nm : string, activity : string)
+setName(nm : string) : void
+getName() : string
+setActivity(activity : string) : void
+getActivity() : string
+printInfo() : void    
print all Pet and Dog information along with name and activity level
    CatAdoptee
    -name : string
-personality : string
values can be cuddly, playful or shy
    +CatAdoptee()
+CatAdoptee(sz : string, a : string, gen : char, hair : string, other : bool, nm : string, pers : string)
+setName(nm : string) : void
+getName() : string
+setPersonality(pers : string) : void
+getPersonality() : string
+printInfo() : void    
print all Pet and Cat information along with name and personality
Code all five classes using header files and putting member function code into separate .cpp files. Be sure to indicate inheritance when you code the header files for Dog, Cat, DogAdoptee and CatAdoptee. Be sure to include the proper header files where needed.
NOTES:
· The constructors of your derived classes should include the parents’ attributes and the cu
ent class attributes. Use the parent’s constructor for the parent’s attributes as shown in the Exercise.
· Your printInfo() methods should call the parent’s printInfo() and add any unique information. No redundant print statements allowed! Use inheritance.
· When printing information on booleans, use an if statement:
    if (houseTrained)
        cout
“This dog is housetrained”
endl;
    else
        cout
“This dog is not housetrained”
endl;
In the main function:
Create a DogAdoptee named “Pugster” that is a medium activity pug who is housetrained. He is considered a small, young male. Print all Pugster’s information with one printInfo() call using the DogAdoptee object.
Create a CatAdoptee named “Holly” that is a cuddly long-haired cat that gets along with other cats well. Holly is a small adult female cat. Print all Holly’s information with one printInfo() call.
Here is some example output; your should be similar but need not be identical:
Submitting Your Assignment
Please copy all 11 files of code into a Word document. Paste in a screenshot of your running program.
Submit the Word document and the complete zipped Project folder.
Answered Same Day Aug 20, 2021

Solution

Piyush answered on Aug 24 2021
154 Votes
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;
}
ool cat::getOtherCats(void){
return otherCats;
}
void cat::printInfo(void){
pet::printInfo();
cout
"The cat hairlength is:\t"
hairlength
endl;
if(otherCats == true){
cout
"The cat is like other cats"
endl;
}else{
cout
"The cat is not like other cats"
endl;
}
}
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"
name
endl;
cout
"The cat personality is:\t"
personality
endl;
}
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(){

eed = "BullDog";
housetrained = true;
}
dog::dog(string sz, string a, char gen, string
d, bool trained):pet(sz,a,gen){

eed =
d;
housetrained = trained;
}
void dog::setBreed(string
d){

eed =
d;
}
string dog::getBreed(void){
return
eed;
}
void dog::setTrained(bool Trained){
housetrained = Trained;
}
ool dog::getTrained(void){
return housetrained;
}
void dog::printInfo(void){
pet::printInfo();
cout
"The
eed of the dog is:\t"
eed
endl;
if(housetrained == true){
cout
"The pet is house trained"
endl;
}else{
cout
"The pet is not house trained"
endl;
}
}
dog.h
#ifndef __DOG_H__
#define __DOG_H__
#include "pet.h"
class dog:public pet{
protected:
string
eed;
bool housetrained;
public:
dog();
dog(string sz, string a, char gen, string
d, bool trained);
void setBreed(string
d);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here