subject

Pet information (derived classes) The base class Pet has private data members petName, and petAge. The derived class Dog extends the Pet class and includes a private data member for dogBreed. Complete main() to:
create a generic pet and print information using PrintInfo().
create a Dog pet, use PrintInfo() to print information, and add a statement to print the dog's breed using the GetBreed() function.
Ex. If the input is:
Dobby
2
Kreacher
3
German Schnauzer
the output is:
Pet Information:
Name: Dobby
Age: 2
Pet Information:
Name: Kreacher
Age: 3
Breed: German Schnauzer

the given code:
Main. cpp:
#include
#include
#include "Dog. h"
using namespace std;
int main() {
string petName, dogName, dogBreed;
int petAge, dogAge;
Pet myPet;
Dog myDog;
getline(cin, petName);
cin >> petAge;
cin. ignore();
getline(cin, dogName);
cin >> dogAge;
cin. ignore();
getline(cin, dogBreed);
// TODO: Create generic pet (using petName, petAge) and then call PrintInfo
// TODO: Create dog pet (using dogName, dogAge, dogBreed) and then call PrintInfo
// TODO: Use GetBreed(), to output the breed of the dog
}



Pet. h

#ifndef PETH
#define PETH

#include
using namespace std;

class Pet {
protected:
string petName;
int petAge;

public:
void SetName(string userName);

string GetName();

void SetAge(int userAge);

int GetAge();

void PrintInfo();
};

#endif
--

Dog. h

#ifndef DOGH
#define DOGH

#include
#include "Pet. h"

class Dog : public Pet {
private:
string dogBreed;

public:
void SetBreed(string userBreed);

string GetBreed();
};

#endif



Pet. cpp

#include "Pet. h"
#include
#include
using namespace std;

void Pet::SetName(string userName) {
petName = userName;
}

string Pet::GetName() {
return petName;
}

void Pet::SetAge(int userAge) {
petAge = userAge;
}

int Pet::GetAge() {
return petAge;
}
void Pet::PrintInfo() {
cout << "Pet Information: " << endl;
cout << " Name: " << petName << endl;
cout << " Age: " << petAge << endl;
}

Dog. cpp
#include "Dog. h"
#include
#include
using namespace std;
void Dog::SetBreed(string userBreed) {
dogBreed = userBreed;
}
string Dog::GetBreed() {
return dogBreed;
}

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, karena13aguirre
Problems: 1. using textbooks, reference books, and internet as your source of research, draw the following microprocessor microarchitectures i. intel 8086 ii. motorola 68000 i atmel atmega32 iv. mips single cycle v. arm cortex-m3 write an hdl module for a hexadecimal seven-segment display decoder. the input is 4-bit binary representing a hex number (0-f), and the output is 8-bit seven segment display bits (a-h). thus, the decoder must handle the digits 10 - 15 to display a-f respectively, in addition to 0-9 numbers. 2. design a 4-bit left and right rotator (both outputs). first sketch schematic diagrams of your design. then implement your design using hdl coding. 3. 4. design a modified priority encoder that receives an 8-bit input, a7: 0 and produces a 3-bit output, y2o. y indicates the most significant bit of the input that is true. y should be 0 if none of the inputs are true. give a simplified boolean equation, sketch a schematic, and write an hdl code. 5.write an 8: 1 multiplexer module called mux8 with selection inputs s, data input d, and data output y. data input (d) and data output (v) are 32-bit wide
Answers: 3
image
Computers and Technology, 22.06.2019 06:50, Mordred809
Type the correct answer in the box. spell all words correctly. which view of report creation allows you to customize the report before the database program creates it? creating a report in allows you to customize the report before the database program creates it. pl asap
Answers: 1
image
Computers and Technology, 22.06.2019 15:30, alexdub9649
What is a costume plot? why is it important to a film or theater production?
Answers: 2
image
Computers and Technology, 22.06.2019 18:00, crimhill
When is it appropriate to use an absolute reference
Answers: 1
You know the right answer?
Pet information (derived classes) The base class Pet has private data members petName, and petAge....

Questions in other subjects:

Konu
Chemistry, 15.04.2021 18:40
Konu
Mathematics, 15.04.2021 18:40
Konu
Mathematics, 15.04.2021 18:40
Konu
History, 15.04.2021 18:40