include using namespace std class DogLicense public void Set

#include <iostream>
using namespace std;

class DogLicense{
public:
void SetYear(int yearRegistered);
void CreateLicenseNum(int customID);
int GetLicenseNum() const;
private:
int licenseYear;
int licenseNum;
};

void DogLicense::SetYear(int yearRegistered) {
licenseYear = yearRegistered;
return;
}

// FIXME: Write CreateLicenseNum()

/* Your solution goes here */

int DogLicense::GetLicenseNum() const {
return licenseNum;
}

int main() {
DogLicense dog1;

dog1.SetYear(2014);
dog1.CreateLicenseNum(777);
cout << \"Dog license: \" << dog1.GetLicenseNum() << endl;

return 0;
}

Challenge 15.2.2: Basic class definition Activity Define the missing function licenseNum is created as: (100000 customID) license Year. Sample outpu Dog license: 77702014 void Create LicenseNumCint customID int GetLicenseNumO const 9 private int license Year; int licenseNum 11 12 13 14 void DogLicense: :SetYear(int yearRegisteredD 1 licenseYear yearRegistered 15 return 17 19 FIXME: Write Create LicenseNumO 20 21 Your solution goes here 22 23 int DogLicense Get LicenseNumO const 1 24 return licenseNum Run Feedback?

Solution

void DogLicense::CreateLicenseNum(int customID) {
licenseNum = customID*100000 + licenseYear ;
return;
}

Above code needs to be insereted.

First check in the declaration area the parameter to be passed, return type and exact name of the function. In the similar way, define the function. The formula is given in the description, so accordingly calculate.

So after inserting this code, program looks as below:

#include <iostream>
using namespace std;
class DogLicense{
public:
void SetYear(int yearRegistered);
void CreateLicenseNum(int customID);
int GetLicenseNum() const;
private:
int licenseYear;
int licenseNum;
};
void DogLicense::SetYear(int yearRegistered) {
licenseYear = yearRegistered;
return;
}


// FIXME: Write CreateLicenseNum()
/* Your solution goes here */

void DogLicense::CreateLicenseNum(int customID) {
licenseNum = customID*100000 + licenseYear ;
return;
}

int DogLicense::GetLicenseNum() const {
return licenseNum;
}
int main() {
DogLicense dog1;
dog1.SetYear(2014);
dog1.CreateLicenseNum(777);
cout << \"Dog license: \" << dog1.GetLicenseNum() << endl;
return 0;
}

And the Output is as below:

Dog license: 77702014

#include <iostream> using namespace std; class DogLicense{ public: void SetYear(int yearRegistered); void CreateLicenseNum(int customID); int GetLicenseNu
#include <iostream> using namespace std; class DogLicense{ public: void SetYear(int yearRegistered); void CreateLicenseNum(int customID); int GetLicenseNu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site