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

C++ code thats need to be commented to help explain it ? #include \"Edit.h\" Edi

ID: 3692945 • Letter: C

Question

C++ code thats need to be commented to help explain it ?

#include "Edit.h"

Edit::Edit()
{
searchName = " ";
newName = " ";
}

Edit::Edit(string sn, string nn)
{
searchName = sn;
newName = nn;
}

Edit::~Edit()
{

}

string Edit::getSearchName() const
{
return searchName;
}

string Edit::getNewName() const
{
return newName;
}

void Edit::setSearchName(string n)
{
searchName = n;
}

void Edit::setNewName(string nn)
{
newName = nn;
}


void Edit::editFunction(vector<Contacts>& myVec)
{
string findName, newName, newNum;

cout << " Which Contact Would You Like to Edit? ";
cin >> findName;

for(unsigned int i = 0; i < myVec.size(); i++)
{
if (myVec[i].getName() == findName)
{
cout << " Success Found Contact: " << myVec[i].getName()
<< " " << myVec[i].getMobNumber() << endl;

cout << " Enter New Name: ";
cin >> newName;
cout << " And Number... ";
cin >> newNum;
myVec[i].setName(newName);
myVec[i].setMobNumber(newNum);
Sleep(1000);
cout << " *Success Contact Has Been Edited*";
return;
}
else { cout << " Sorry Contact Not Found" << endl; }
}
}

Explanation / Answer


#include "Edit.h" /* library needed */
Edit::Edit() /* Class instantiation */
{
searchName = " "; /* initialize object searchName */
newName = " "; /* initialize object newName */
}
Edit::Edit(string sn, string nn) /* two parameters type string to the constructor of the class */
{
searchName = sn; /* incoming object allocation searchName */
newName = nn; /* incoming object allocation newName */
}
Edit::~Edit() /* Unary complement */
{
}
string Edit::getSearchName() const /* iinstantiation of the method to Get the string searchName*/
{
return searchName; /* returning the value of type string searchName*/
}
string Edit::getNewName() const /* instantiation of the method to Get the string newName*/
{
return newName; /* returning the value of type string newName*/
}
void Edit::setSearchName(string n) /* instantiation of the method to Set the string searchName*/
{
searchName = n; /* inserts the value of the string searchName*/
}
void Edit::setNewName(string nn) /* instantiation of the method to Set the string newName*/
{
newName = nn; /* inserts the value of the string newName*/
}

void Edit::editFunction(vector<Contacts>& myVec) /* instantiation of the method edit function that receives an array as a parameter with a proportional size to the existing list of contacts */
{
string findName, newName, newNum; /* Auxiliary Declaration type String */
cout << " Which Contact Would You Like to Edit? ";
cin >> findName; /* store user input */
for(unsigned int i = 0; i < myVec.size(); i++) /* Go from beginning to end of myVec */

{
if (myVec[i].getName() == findName) /* Enters the conditional if the comparison of the name found is equal to enter user */
{
cout << " Success Found Contact: " << myVec[i].getName() /* shows contact list */
<< " " << myVec[i].getMobNumber() << endl;
cout << " Enter New Name: "; /* Enter user the new name */
cin >> newName; /* store user input */
cout << " And Number... ";
cin >> newNum; /* store user input */
myVec[i].setName(newName); /* Enter user in myVe*/
myVec[i].setMobNumber(newNum); /* Enter user in myVe*/
Sleep(1000); /* small space waiting */
cout << " *Success Contact Has Been Edited*";
return;
}
else { cout << " Sorry Contact Not Found" << endl; } /* If the comparison is not equal yields the following */
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote