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

C++ Programming Help Needed (3) files listed in Body. Purpose: Implement the sim

ID: 3856273 • Letter: C

Question

C++ Programming Help Needed (3) files listed in Body.

Purpose: Implement the simple Contact management application as a Windows console application.
Requirements: You are provided with three source files. Implement your code per below instructions for each file:
ContactRecord.h - This header file contains the class definition of the ContactRecord class. You need to provide the implementation for each of its member functions and constructors.

###
#pragma once
#include <iostream>
#include <string>
using namespace std;
class ContactRecord
{
private:
int ContactID;
string FirstName;
string LastName;
string MiddleName;
string PhoneNumber;
private:
void CopyData(const ContactRecord & src);
public:
int GetContactID() { return this->ContactID; }
string GetFirstName() { return this->FirstName; }
string GetLastName() { return this->LastName; }
string GetMiddleName() { return this->MiddleName; }
string GetPhoneNumber() { return this->PhoneNumber; }
void SetContactID(int v) { this->ContactID = v;}
void SetFirstName(string v) { this->FirstName = v; }
void SetLastName(string v) { this->LastName = v; }
void SetMiddleName(string v) { this->MiddleName = v; }
void SetPhoneNumber(string v) { this->PhoneNumber = v; }
public:
void Print() const;
public:
ContactRecord();
ContactRecord(string firstName, string lastName, string middleName, string phoneNumber);
ContactRecord(const ContactRecord & src);
public:
const ContactRecord & operator=(const ContactRecord & src);
bool operator==(const ContactRecord & src);
};
###

ContactDataManager.h - This header file contains the class definition of the ContactDataManager class. The ContactDataManager class manages the list (vector) of ContactRecord objects. You need to provide the implementation for each of its member functions and constructors.

###
#pragma once
#include <vector>
#include "ContactRecord.h"

class ContactDataManager
{
private:
static int NextContactID;
private:
vector<ContactRecord> ContactList;
private:
void CopyData(const ContactDataManager & src);
public:
ContactDataManager();
ContactDataManager(const ContactDataManager & src);
public:
size_t GetContactCount();
int AddContact(string firstName, string lastName, string middleName, string phoneNumber);
bool EditContact(int nContactID, string firstName, string lastName, string middleName, string phoneNumber);
bool RemoveContact(int nContactID);
bool RetrieveContact(int nContactID, ContactRecord & contact);
vector<int> GetContactIDs();
public:
const ContactDataManager operator=(const ContactDataManager & src);
};
###

Main.cpp - This source file contains the implementation of the main() method. Do not modify this file. Include it in your project. Your ContactRecord and ContactDataManager classes will need to work with this source file.

###
#include "ContactRecord.h"
#include "ContactDataManager.h"

int main(int argc, char *argv[], char *envp[])
{
ContactDataManager contactDataManager;
contactDataManager.AddContact("Peter", "Nguyen", "", "123456789");
contactDataManager.AddContact("Kim", "Vo", "Hai", "987654321");
contactDataManager.AddContact("John", "Smith", "Jr.", "112233445566");
contactDataManager.AddContact("Hung", "Bach", "", "3344556677");
vector<int> contactIds = contactDataManager.GetContactIDs();
cout << "***** CONTACTS BEFORE EDIT *****" << endl;
for (size_t i = 0; i < contactIds.size(); i++)
{
ContactRecord rec;
contactDataManager.RetrieveContact(contactIds[i], rec);
rec.Print();
}
cout << endl;
contactDataManager.EditContact(contactIds[0],
"Peter",
"Nguyen",
"S.",
"66666666");
cout << "***** CONTACTS AFTER EDIT *****" << endl;
for (size_t i = 0; i < contactIds.size(); i++)
{
ContactRecord rec;
contactDataManager.RetrieveContact(contactIds[i], rec);
rec.Print();
}
cout << endl;
contactDataManager.RemoveContact(contactIds[1]);
cout << "***** CONTACTS AFTER REMOVE *****" << endl;
contactIds = contactDataManager.GetContactIDs();
for (size_t i = 0; i < contactIds.size(); i++)
{
ContactRecord rec;
contactDataManager.RetrieveContact(contactIds[i], rec);
rec.Print();
}
cout << endl;
return 0;
}
###

Explanation / Answer

#include #include #include using namespace std; /* List Node: */ template class MyNode { private: T data; public: MyNode* next; MyNode* previous; MyNode(T data); T getData(); string toString(); ~MyNode(); }; template MyNode::MyNode(T data) { this->data = data; } template T MyNode::getData() { return this->data; } template string MyNode::toString() { stringstream s; s head = NULL; this->tail = NULL; this->list_size = 0; } template T* MyList::getHead() { return this->head; } template T* MyList::getTail() { return this->tail; } template int MyList::size(bool update) { if (!update) { return this->list_size; } int size = 0; T* temp = this->head; while (temp) { size++; temp = temp->next; } this->list_size = size; return this->list_size; } template void MyList::addNodeAsTail(T* new_node) { new_node->next = NULL; new_node->previous = NULL; if (this->head == NULL) { this->head = new_node; this->tail = this->head; this->list_size = this->list_size + 1; } else { this->tail->next = new_node; new_node->previous = this->tail; this->tail = new_node; this->list_size = this->list_size + 1; } } template void MyList::addNodeAsHead(T* new_node) { new_node->next = NULL; new_node->previous = NULL; if (this->head == NULL) { this->head = new_node; this->tail = this->head; this->list_size = this->list_size + 1; } else { this->head->previous = new_node; new_node->next = this->head; this->head = new_node; this->list_size = this->list_size + 1; } } template void MyList::push(T* new_node) { this->addNodeAsHead(new_node); } template T* MyList::pop() { T* temp = this->head; this->head = this->head->next; this->head->previous = NULL; this->list_size = this->list_size - 1; return temp; } template T* MyList::peek() { return this->head; } template void MyList::enqueue(T* new_node) { this->addNodeAsTail(new_node); } template T* MyList::dequeue() { return this->pop(); } template T* MyList::get(int index) { if (index == 0) { return this->head; } else if (index == this->list_size - 1) { return this->tail; } else if (index < 0 || index >= this->list_size) { return NULL; } if (index list_size / 2) { T* temp = this->head; int i = 0; while (temp) { if (i == index) { return temp; } i++; temp = temp->next; } } else { T* temp = this->tail; int i = this->list_size - 1; while (temp) { if (i == index) { return temp; } i--; temp = temp->previous; } } return NULL; } template void MyList::printList() { cout head; while(temp) { cout next; } cout list_size - 1; this->head = next; } } void stackAsString() { MyList stack; int i = 0; cout
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