Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a base class named Animal to allow the following public data members: The

ID: 3536403 • Letter: D

Question

Design a base class named Animal to allow the following public data members:

The Animal class must also allow a public void function named printValues with no parameters.

Design a derived class named vetPatient that inherits all of the properties of the base class Animal as public members and has the following additional private members:

Design a derived class named Pet that inherits all of the properties of the base class Animal as private members and has the following additional public members:

Because the base class data members are private for the derived class Pet, the function printValues needs parameters for the Animal class data members.

Design three printValues functions - one for each class: Animal, vetPatient, and Pet - that will display all data members for the object of that class and then call the printValues function of the Animal class when necessary to display private data members of the base class.

Design a main function to test he classes that you created. Include all comments for documentation and identification of the program in your design. Create an object name elephant of the type Animal, an object named horse as the type vetPatient, and an object named dog as the type Pet. For gender, use 'm' for male, 'f' for female, 'n' for a neutered male, and 's' for a spayed female. You can expect a male elephant to live 65 years and weigh around 7 tons(14,000 pounds). Depending on the breed you can expect a dog that has been spayed to live 12 years and weigh around 20 pounds. A dog can be an indoor or outdoor pet and may or may not bite. You can expect a female racehorse to live 25 years, weigh around 1,000 pounds, and have regular exams by a veterinarian. Using thes facts, assign values to each data member in the class and call the printValues functions to output the values after they have been assigned.

Write a C++ program based on the designs you created.

The following is a copy of the screen results that display after running the program.


A male elephant named Jumbo should live to be 65 and

weigh 14000 pounds.

A female horse name Pretty Filly should live to be 25

and weigh 1000 pounds.

The horse checked in 8/30/2013 and checked out

8/31/2012.

The procedure preformed was a checkup at a cost of

$158.00.

A spayed dog named Fifi should live to be 12 and weigh

20 pounds.

Your dog lives indoors and does not bite.


Program Must be In one Source file... no headers

Explanation / Answer

#include<iostream.h>

#include<conio.h>

class Animal

{

int lifeExpectancy,weight;

char gender;

string name,type;

public:

void setValue(int l,int w,char g,char n[],char t[])

{ lifeExpectancy=l;

weight=w;

gender=g;

name=n;

type=t;

}


void printValues()

{

cout<<" Life Expectancy:"<<lifeExpectancy;

cout<<" Weight:"<<weight<<"pounds";

if(gender=='m'||gender=='M')

cout<<" Gender:Male";

else if(gender=='f'||gender=='F')

cout<<" Gender:Female";

else if(gender=='n'||gender=='N')

cout<<" Gender:Neutral";

else

cout<<" Gender:SpayFemail";

cout<<" Name:"<<name;

cout<<" Type:"<<type;

}




};

class vetPatient:public Animal

{

date dateIn,dateOut;

double charges;

char procedure[30];

void setValues(int l,int w,char g,char n[],char t[],char in,char o,double ch,char pro)

{

dateIn=in;

dateOut=o;

charges=ch;

procedure=pro;

lifeExpectancy=l;

weight=w;

gender=g;

name=n;

type=t;

}


} ;

class Pet:private Animal

{

public:

string home;

bool bites;

void setValues(int l,int w,char g,char n[],char t[],char h,int b)

{

lifeExpectancy=l;

weight=w;

gender=g;

name=n;

type=t;

home=h;

bites=b;

}


} ;


void main()

{

Animal elephant;

elephant.setValue(65,14000,'m',"Elephant","African");

vetPatient horse;

Pet dog;

elephant.printValues();

horse.printValues();

dog.printValues();

getch();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote