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

i just need what 2 segments do. Here are some code sample as follows: choose som

ID: 3676836 • Letter: I

Question

i just need what 2 segments do. Here are some code sample as follows: choose some code segments and elaborate further as to what these code segments accomplish - expound on it:

#include ". esistor.h"
#include <iostream>

using namespace std;

   //CResistor argument constructor
   CResistor::CResistor(double nomRes, double tol, string resName, bool fnDisplay)
   {
       if(fnDisplay)
           cout << endl << "CResistor constructor called" << endl;
       nominalResistance = nomRes;
       tolerance = tol;
       resistorName = resName;
   }

   //CResistor destructor
   CResistor::~CResistor()
   {
   }

   //CResistor nominal resistance getter/accessor function
   double CResistor::getNominal(bool fnDisplay)
   {
       if(fnDisplay)
           cout << endl << "getNominal getter-accessor fuction called" << endl;
       return(nominalResistance);
   }



   //CResistor nominal resistance setter/mutator function
   void CResistor::setNominal(double nomRes, bool fnDisplay)
   {
       if(fnDisplay)
           cout << endl << "setNominal setter-mutator fuction called" << endl;
       nominalResistance = nomRes;
   }

   //CResistor resistance tolerance getter/accessor function
   double CResistor::getTolerance(bool fnDisplay)
   {
       if(fnDisplay)
           cout << endl << "getTolerance getter-accessor fuction called" << endl;
       return(tolerance);
   }

   //CResistor resistance tolerance setter/mutator function
   void CResistor::setTolerance(double resTol, bool fnDisplay)
   {
       if(fnDisplay)
           cout << endl << "setTolerance setter-mutator fuction called" << endl;
       tolerance = resTol;
   }

   //CResistor object name getter/accessor function
   string CResistor::getResName(bool fnDisplay)
   {
       if(fnDisplay)
           cout << endl << "getResName getter-accessor fuction called" << endl;
       return resistorName;
   }


   //CResistor object name setter/mutator function
   void CResistor::setResName(string resName, bool fnDisplay)
   {
       if(fnDisplay)
           cout << endl << "setResName setter-mutator fuction called" << endl;
       resistorName = resName;
   }

Explanation / Answer

CResistor::CResistor(double nomRes, double tol, string resName, bool fnDisplay)
{
if(fnDisplay)
cout << endl << "CResistor constructor called" << endl;
nominalResistance = nomRes;
tolerance = tol;
resistorName = resName;
}

If I consider this Parametrised constructor will assign the values to CResistor class data members. but here one condition is present.
i.e if(fnDisplay) is true then only cout statement will called and will display the message on console..
"CResistor constructor called"
  
Second Part:

//CResistor nominal resistance getter/accessor function
double CResistor::getNominal(bool fnDisplay)
{
if(fnDisplay)
cout << endl << "getNominal getter-accessor fuction called" << endl;
return(nominalResistance);
}

This above code will return the nominalResistance value to where function is called and
it has one more if condition is true then it will print "getNominal getter-accessor fuction called"

Third Part:

//CResistor nominal resistance setter/mutator function
void CResistor::setNominal(double nomRes, bool fnDisplay)
{
if(fnDisplay)
cout << endl << "setNominal setter-mutator fuction called" << endl;
nominalResistance = nomRes;
}
  
This function will set the value to nominalResistance with help of setNominal function.