Question

In: Computer Science

Debug the pet.h file and pet.cpp file (I would like to check my work) #ifnotdef PET_H...

Debug the pet.h file and pet.cpp file (I would like to check my work)

#ifnotdef PET_H

#then_define PET_H

#include <string>

using name space std

namespace fhsuzeng

{

Class Pet

{

public

Pet();

void setName(string name);

string getName() const;

void setAge(double age);

int getAge() const;

virtual void talk();

private:

string _name; int _age;

};

class Dog::public Pet

{

public:

Dog();

void setBreed(string breed);

string getBreed() const;

private: string _breed;

}

class Cat:Pet

{

Public:

Cat();

void setColor(string color);

string getColor() const;

private:

string _color;

};

}; #endif

The above is pet.h file and the following is the file pet.cpp

#include <string>

#include <pet.h>

using name space std

namespace fhsuzeng

{

void Pet::Pet():: _name("no name yet"), _age(0){}

int Pet::getAge() const { return age; }

void Pet::setAge(int age) { age = age; }

string Pet::getName() const { return _name }

void Pet::setName(string name) { _name = name; }

Pet::Dog(): Pet(), _breed("Any breed") {}

string Dog::getBreed() { return _breed; }

void Dog::setBreed(string breed) { _breed = breed; }

Cat::Cat(): Pet(), _color("Red")

Cat::string getColor() const { return _color; }

void Cat:: setColor(string color) { _color = color; } }

Solutions

Expert Solution

pet.h:

Raw_code:

#ifndef PET_H
#define PET_H
#include <string>
using namespace std;
namespace fhsuzeng{
class Pet{
public:
Pet();
void setName(string name);
string getName() const;
void setAge(int age);
int getAge() const;
private:
string _name; int _age;
};

class Dog:public Pet{
public:
Dog();
void setBreed(string breed);
string getBreed() const;
private: string _breed;
};
class Cat:public Pet{
public:
Cat();
void setColor(string color);
string getColor() const;
private:
string _color;
};
}
#endif

pet.cpp:

Raw_code:

#include <string>
#include "pet.h"
using namespace std;
namespace fhsuzeng{
Pet::Pet(): _name("no name yet"), _age(0){}
int Pet::getAge() const { return _age; }
void Pet::setAge(int age) { _age = age; }
string Pet::getName() const { return _name; }
void Pet::setName(string name) { _name = name; }

Dog::Dog(): Pet(), _breed("Any breed") {}
string Dog::getBreed() const{ return _breed; }
void Dog::setBreed(string breed) { _breed = breed; }

Cat::Cat(): Pet(), _color("Red"){}
string Cat::getColor() const { return _color; }
void Cat::setColor(string color) { _color = color; }
}

main.cpp:

Raw_code:

#include<iostream>
#include"pet.cpp"
using namespace std;
using namespace fhsuzeng;

int main(){
Pet pet = Pet();
cout<<"Pet: "<<pet.getName()<<endl;
pet.setName("Jimmy");
pet.setAge(9);
cout<<"pet name: "<<pet.getName()<<"\tage: "<<pet.getAge()<<endl<<endl;

Dog dog = Dog();
cout<<"Dog: "<<dog.getBreed()<<endl;
dog.setName("Browny");
dog.setBreed("Pamorian");
dog.setAge(5);
cout<<"Dog name: "<<dog.getName()<<"\tbreed: "<<dog.getBreed()<<"\tage: "<<dog.getAge()<<endl<<endl;

Cat cat = Cat();
cout<<"Cat: "<<cat.getColor()<<endl;
cat.setColor("Black");
cat.setName("Tommy");
cat.setAge(4);
cout<<"Cat name: "<<cat.getName()<<"\tcolor: "<<cat.getColor()<<"\t age: "<<cat.getAge()<<endl<<endl;
}

output:


Related Solutions

I work in Supply Chain in the Procurement Dept. I would like to use my dept...
I work in Supply Chain in the Procurement Dept. I would like to use my dept for this assignment. Please do not copy what's already in Chegg. Process Improvement Project For this assignment select either your own organization or an organization about which you know enough to review the supply chain processes and identify a process that can be improved in your sphere of influence. Phase I: Improvement Opportunity Write 500-750 words on improvement opportunity in your sphere of influence....
pls answer 1-4 I would like to check with my answer 1) Saponification of triglycerides gives...
pls answer 1-4 I would like to check with my answer 1) Saponification of triglycerides gives glycerol and fatty acid salts as shown in the equation below. The groups R1, R2 and R3 represent hydrocarbon chains that may be the same or different. Saponification is actually a hydrolysis reaction. Explain what a hydrolysis reaction is and the role of sodium hydroxide in this process. 2)The over-the-counter drug Ibuprofen is a 1:1 mixture of R and S isomers of the compound...
I've did most of the work i just need someone to check if my work is...
I've did most of the work i just need someone to check if my work is correct Maryam and Hanadi are planning to open a shop to sell female shoes in Abu Dhabi. The venue of the shop is decided to be a rented premises in Marina Mall. They wish to start their operations from 01 July, 2020. The following information is available about the company’s operations. i. The company predicts a sale price of AED 350 per unit. Sales...
Item Skipped eBook Print References Check my work Check My Work button is now enabled Item...
Item Skipped eBook Print References Check my work Check My Work button is now enabled Item 2 Item 2 10 points Item Skipped North Bank has been borrowing in the U.S. markets and lending abroad, thereby incurring foreign exchange risk. In a recent transaction, it issued a one-year $2.00 million CD at 4 percent and is planning to fund a loan in British pounds at 6 percent for a 2 percent expected spread. The spot rate of U.S. dollars for...
Check my work check My Work button is now enabled1 Item 1 Item 1 Part 1...
Check my work check My Work button is now enabled1 Item 1 Item 1 Part 1 of 2 1.66 points Required information Use the following information for the Exercises below. [The following information applies to the questions displayed below.] Laker Company reported the following January purchases and sales data for its only product. Date Activities Units Acquired at Cost Units sold at Retail Jan. 1 Beginning inventory 155 units @ $ 8.00 = $ 1,240 Jan. 10 Sales 115 units...
How would I work the following problems out? I would like someone to show their work...
How would I work the following problems out? I would like someone to show their work so I could better understand the answers and thought process. Genetics Problems For the first couple of problems, you will be working with guinea pigs. Their coat color shows an example of complete dominance - black (B) is dominant over brown (b). 1. A heterozygous black male is crossed with a heterozygous black female. What would be the resulting phenotypic ratio in the offspring?...
Can you please check my work? I used R but it's very basic. I searched for...
Can you please check my work? I used R but it's very basic. I searched for this question on Chegg to check my answer but my numbers are slightly different. What did I do wrong? Question: Calculate confidence intervals for population variance and standard deviation. Assume that samples are simple random samples and taken from a normal population. α=0.05, sample size=30,s=3.5 stdev =3.5 df = 29 n = 30 alpha = 0.05 qchisq(0.05,df,lower.tail = FALSE) onechi <- 42.55679 #[1] 42.55697...
I am struggling with easy problem. Can you pls check my work ? The patient is...
I am struggling with easy problem. Can you pls check my work ? The patient is to receive 500 mL of D5W over 6 hours . What is the drip rate per minute if the tubing provides 12 gtts per mL? Gtt/min 12gtt/ml x 500/360 min =6000/360=118 gtt/min A patient who weighs 74 pounds has an order for Advil (ibuprofen) 3.5 mg/kg every 6 hours. How many mg will you give in a single dose? 3,5MG /KG X33.6KG =118 MG...
Time Remaining 3 hours 5 minutes 26 seconds 03:05:26 eBook Check my work Check My Work...
Time Remaining 3 hours 5 minutes 26 seconds 03:05:26 eBook Check my work Check My Work button is now disabled Item 3 Item 3 Time Remaining 3 hours 5 minutes 26 seconds 03:05:26 Polaski Company manufactures and sells a single product called a Ret. Operating at capacity, the company can produce and sell 38,000 Rets per year. Costs associated with this level of production and sales are given below: Unit Total Direct materials $ 20 $ 760,000 Direct labor 10...
I am in a statistics class. When I graduate, I would like to work in an...
I am in a statistics class. When I graduate, I would like to work in an area where I can help restructure businesses that are failing and make them successful. My professor has asked me where in my career that I think I will use the process of data collection. He has asked me to provide 2 examples. This is my first statistics class, so I don't really know of how to give him any examples. Can you please give...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT