1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
JulsSmile [24]
3 years ago
8

Define a member function PrintAll() for class PetData that prints output as follows. Hint: Make use of the base class' PrintAll(

) function.
Name: Fluffy, Age: 5, ID: 4444
Given this code:

#include
#include
using namespace std;

class AnimalData {
public:
void SetName(string givenName) {
fullName = givenName;
};
void SetAge(int numYears) {
ageYears = numYears;
};
// Other parts omitted

void PrintAll() {
cout << "Name: " << fullName;
cout << ", Age: " << ageYears;
};

private:
int ageYears;
string fullName;
};

class PetData: public AnimalData {
public:
void SetID(int petID) {
idNum = petID;
};

// FIXME: Add PrintAll() member function

/* Your solution goes here */

private:
int idNum;
};

int main() {
PetData userPet;

userPet.SetName("Fluffy");
userPet.SetAge (5);
userPet.SetID (4444);
userPet.PrintAll();
cout << endl;

return 0;
}
Computers and Technology
1 answer:
PilotLPTM [1.2K]3 years ago
8 0

Answer:

Following are the program in the C++ Programming Language.

//set header file

#include <iostream>

//set header file for string

#include <string>

//set namespace

using namespace std;

//define class

class AnimalData

{

//set access modifier

public:

//define function

void SetName(string givenName)

{

//initialize the value of function's argument

fullName = givenName;

};

//define function

void SetAge(int numYears)

{

//initialize the value of function's argument

ageYears = numYears;

};  

//here is the solution

//define function

void PrintAll()

{

//print output with message

cout << "Name: " << fullName<<endl;

//print output with message

cout << "Age: " << ageYears<<endl;

};

//set access modifier

private:

//set integer data type variable

int ageYears;

//set string data type variable

string fullName;

};

//define class and inherit the parent class

class PetData: public AnimalData

{

//set access modifier

public:

//define function

void SetID(int petID)

{

idNum = petID;

};

//override the function for print id

void PrintAll()

{

AnimalData::PrintAll();

cout << "ID: " <<idNum ;

};

//set access modifier

private:

//set integer type variables

int idNum,fullName,ageYears;

};

//define main method

int main()

{

//create object of the child class

PetData userPet;

//call function through object

userPet.SetName("Fluffy");

//call function through object

userPet.SetAge (5);

//call function through object

userPet.SetID (4444);

//call function through object

userPet.PrintAll();

cout << endl;

return 0;

}

<u>Output</u>:

Name: Fluffy

Age: 5

ID: 4444

Explanation:

<u>Following are the description of the program</u>:

  • Set required header file and namespace.
  • Define class 'AnimalData' and inside the class, set integer data type variable 'ageYears', string data type variable 'fullName'.
  1. Then, define function 'SetName()' with string data type argument 'givenName' and initialize the value of argument in the string variable.
  2. Then, define function 'SetAge()' with integer data type argument 'numYears' and initialize the value of the argument in the integer variable.
  3. Define function 'PrintAll()' to print the value of the following variables with message.
  • Define class 'PetData' and inherit the parent class in it, then set integer data type variable 'idNum'.
  1. Then, define function 'SetID()' with integer data type argument 'petID' and initialize the value of the argument in the integer variable.
  2. Override the function 'PrintAll()' to print the value of the following variable with message.

Finally, define main method and create the object of the child class, then call the following functions through the class object.

You might be interested in
What is the name of the organization responsible for assigning public ip​ addresses?.
IgorC [24]

The worldwide body in charge of managing and supervising the coordination of the Internet's domain name system  is called the Internet Corporation for Assigned Names and Numbers (ICANN).

The Internet Engineering Task Force (IETF) is a sizable, open, and global community of network architects, operators, vendors, and academics with a focus on the development of the Internet architecture and the efficiency of its operation. Any anybody with an interest is welcome to join the IETF.

The IETF's working groups, which are categorized into various sections by topic, carry out the technical work for the organization (e.g., routing, transport, security, and more). Three times a year, the IETF organizes meetings, but the majority of the work is done via mailing list.

To know more about Internet  click here:

brainly.com/question/5787501

#SPJ4

6 0
1 year ago
Suppose you repeatedly roll a fair six-sided die until you roll a 1 (and then you stop). Every time you roll a 2, you lose a poi
OverLord2011 [107]

Answer:

E = b-a

Explanation:

In this questions what we are been asked is for the expected value E, to solve the problem we need to recognize the random variables and their respective probability.

  • x1 = roll a 1 -> P1 = 1/6
  • x2 = roll a 2 -> P2 = 1/6
  • x3 = roll a 6 -> P3 = 1/6
  • x4 = roll a 1, 4 or 5 -> P4 = 1/2

E = P1*x1 + P2*x2 + P3*x2 + P4*x4

x1 is equal to zero (no points and the game stop), x2 is equal to E-a (lose a points, affecting the expected value), x3 is equal to E+b (win b points, affecting the expected value) and x4 is equal E (no points are lost and the game continues, therefore the expected value is not affected)

E = 1/6*0 + 1/6*(E-a) + 1/6*(E+b) + 1/2*(E)

1/6*E = 1/6*b - 1/6a

Solving for E

E = b-a

Conclusion: If you get a 3, 4 or 5 the game is unaffected (in terms of points), you need to pay special attention to x1, x2 and x3 (all with the same probability)  that are the results that are going to affect your game.  

7 0
3 years ago
Ian is creating an oversized poster for the local Battle of the Bands event that will need to be printed in color. Which softwar
amid [387]

Answer:

B. Adobe InDesign

Explanation:

Adobe Indesign is a software application, created by creative cloud adobe systems, used for typesetting and desktop publishing, to create flyers, bronchures, magazines, newspapers, presentations, posters, books and ebook.

Adobe Edge and Dreamweaver are also creative cloud adobe system packages used as web development tools to edit html, css, javascript file etc.

Microsoft office word is a Microsoft office package used to create text documents.

8 0
3 years ago
What are some effects of the holocaust? She walked along the river until a policeman stopped her. It was one o'clock, he said. N
Gnoma [55]
B............................................................
7 0
3 years ago
Which of the following is a result of gravity in relation to moving tectonic plates?
Radda [10]
I am not sure but here is a guess I think it might be C- earth's magnetic field reverses
4 0
3 years ago
Read 2 more answers
Other questions:
  • When using an hdmi to dvi adapter, what two dvi port types will the adapter work with?
    8·1 answer
  • Create a recursive method, a method that calls itself, that returns true or false depending on whether or not a given string is
    6·1 answer
  • Bob received a message from Alice which she signed using a digital signature. Which key does Bob use to verify the signature?Gro
    13·1 answer
  • What are tags?
    13·1 answer
  • Def build_dictionary(string):
    13·1 answer
  • What is the answer to this question?
    11·1 answer
  • Consider the following code:
    12·1 answer
  • The "great big secret" Ohanian talks about is the idea that:
    15·1 answer
  • For any element in keysList with a value smaller than 40, print the corresponding value in itemsList, followed by a comma (no sp
    6·1 answer
  • Advantages &amp; Disadvantages of flow chart​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!