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

Customer List (1) CustomerList() and ~CustomerList() - default constructor and d

ID: 3796848 • Letter: C

Question

Customer List

(1) CustomerList() and ~CustomerList() - default constructor and destructor.

(2) bool addStore(Store*s) - Add an instance of store to the linked list. Return true if successful.

(3) Store *removeStore(int ID) - Locate a Store in the list if it exists, remove and return it.

(4) Store *getStore(int ID) - Locate a Store in the list and return a pointer to it.

(5) bool updateStore(int ID, char *name, char *addr, char *city, char *st, char *zip) - Locate a store in the list then update all its information. Return true if successful.

(6) void printStoreInfo() - Iterate over the list of store and have each print itself.

Employee Record

(1) Add a pointer to a class of type CustomerList called m_pCustomerList.

(2) Add a function CustomerList *getCustomerList to return the pointer to the EmployeeRecord's CustomerList object.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

CustomerList - header

---------------------------------

#pragma once;

#include
#include "Store.h"

class CustomerList
{

   private:
   Store *m_pHead;

   public:
       CustomerList();
       ~CustomerList();
       bool addStore(Store *s);
       Store *removeStore(int ID);
       Store *getStore(int ID);
       bool updateStore(int ID, char *name, char *addr, char *city, char *st, char *zip);
       void printStoresInfo();

  
};

*****************************************************************************************************************************************************

CustomerList Main

-------------------------------

#include
#include
#include "CustomerList.h"

using namespace std;

CustomerList::CustomerList()
{
  

}

CustomerList::~CustomerList()
{


}

bool CustomerList:: addStore(Store *s)
{
  
}

Store *CustomerList::removeStore(int ID)
{

}

Store *CustomerList::getStore(int ID)
{

}

bool CustomerList::updateStore(int ID, char *name, char *addr, char *city, char *st, char *zip)
{

}

void CustomerList::printStoresInfo()
{

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Store header file

---------------------------

#pragma once;

#include
#include

using namespace std;

class Store
{
   private:
       int       m_iStoreID;
       char   m_sStoreName[64];
       char   m_sAddress[64];
       char   m_sCity[32];
       char   m_sState[32];
       char   m_sZip[11];

   public:
       Store   *m_pNext;

       Store();                       // Default constructor
       Store(int ID,                   // Constructor
           char *name,
           char *addr,
           char *city,
           char *st,
           char *zip);
       ~Store();                       // Destructor
       int getStoreID();               // Get/Set store ID
       void setStoreID(int ID);
       char *getStoreName();           // Get/Set store name
       void setStoreName(char *name);
       char *getStoreAddress();       // Get/Set store address
       void setStoreAddress(char *addr);
       char *getStoreCity();           // Get/Set store city
       void setStoreCity(char *city);
       char *getStoreState();           // Get/Set store state
       void setStoreState(char *state);
       char *getStoreZip();           // Get/Set store zip code
       void setStoreZip(char *zip);
       void printStoreInfo();           // Print all info on this store
};

*****************************************************************************************************************************************************

Store Main

-------------------------------------------------

#include "Store.h"
#include

using namespace std;


// Default Constructor

Store::Store()
{
   m_pNext = NULL;
}


// Constructor

Store::Store(int ID, char *name, char *addr, char *city, char *st, char *zip)
{
   m_iStoreID = ID;
   strcpy(m_sStoreName, name);
   strcpy(m_sAddress, addr);
   strcpy(m_sCity, city);
   strcpy(m_sState, st);
   strcpy(m_sZip, zip);
   m_pNext = NULL;
}


// Destructor

Store::~Store()
{
   // Nothing to do here
}



int Store::getStoreID()
{
   return m_iStoreID;
}


void Store::setStoreID(int ID)
{
   m_iStoreID = ID;
}


char *Store::getStoreName()
{
   char *name = new char[strlen(m_sStoreName) + 1];
   strcpy(name, m_sStoreName);
   return name;
}


void Store::setStoreName(char *name)
{
   strcpy(m_sStoreName, name);
}


char *Store::getStoreAddress()
{
   char *addr = new char[strlen(m_sAddress) + 1];
   strcpy(addr, m_sAddress);
   return addr;
}


void Store::setStoreAddress(char *addr)
{
   strcpy(m_sAddress, addr);
}


char *Store::getStoreCity()
{
   char *city = new char[strlen(m_sCity) + 1];
   strcpy(city, m_sCity);
   return city;
}


void Store::setStoreCity(char *city)
{
   strcpy(m_sCity, city);
}


char *Store::getStoreState()
{
   char *state = new char[strlen(m_sState) + 1];
   strcpy(state, m_sState);
   return state;
}


void Store::setStoreState(char *state)
{
   strcpy(m_sState, state);
}


char *Store::getStoreZip()
{
   char *zip = new char[strlen(m_sZip) + 1];
   strcpy(zip, m_sZip);
   return zip;
}


void Store::setStoreZip(char *zip)
{
   strcpy(m_sZip, zip);
}


void Store::printStoreInfo()
{
   cout << m_iStoreID << setw(20) << m_sStoreName << setw(15) << m_sAddress
       << setw(15) << m_sCity << ", " << m_sState << setw(10) << m_sZip << " ";
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Employee Record header file

--------------------------

#pragma once

#include "CustomerList.h"

class EmployeeRecord
{
private:
int m_iEmployeeID;
char m_sLastName[32];
char m_sFirstName[32];
int m_iDeptID;
double m_dSalary;

public:
           //The default constructor
EmployeeRecord();

           // Constructor shall set the member values passed into the function.
       EmployeeRecord(int ID, char *fName, char *lName, int dept, double sal);

           // The destructor
~EmployeeRecord();

       // shall return the value stored in the member variable
int getID();

       // will set the member variable m_iEmployeeID to the value of its' argument.
void setID(int ID);

       // The getName() function shall copy the member variables m_sFirstName and m_sLastName into the character arrays pointed to by the function arguments.
void getName(char *fName, char *lName);

       // The setName() function will copy the function arguments into the member variables m_sFirstName and m_sLastName
void setName(char *fName, char *lName);

       // The getDept() function shall be defined as a reference function. That is, a call to this function will copy the member variable m_iDeptID into the int variable referenced by the function argument.
int getDept();

           // The setDept() function will copy the function argument into the member variable m_iDeptID.
void setDept(int d);

           // The getSalary() function shall be defined as a pointer function.
double getSalary();

       // The function setSalary() shall copy the function argument into the member variable m_dSalary.
void setSalary(double sal);

       //This function shall print to the screen all data found in the employee's record
void printRecord();

       CustomerList *getCustomerList();
       CustomerList *m_pCustomerList;
};

*****************************************************************************************************************************************************

Employee Record Main

---------------------------------

#include
#include "EmployeeRecord.h"

using namespace std;

//Default Constructor

EmployeeRecord::EmployeeRecord()
{

// The default constructor shall set the member variables to the following
m_iEmployeeID = 0;
m_sFirstName[0] = '';
m_sLastName[0] = '';
m_iDeptID = 0;
m_dSalary = 0.0;
}


EmployeeRecord::EmployeeRecord(int ID, char *fName, char *lName, int dept, double sal)
{

// Copying the member varibles for First and Last name
strcpy(m_sFirstName, fName);
strcpy(m_sLastName, lName);

// Copying other member variables
m_iEmployeeID = ID;
m_iDeptID = dept;
m_dSalary = sal;
fName = NULL;
lName = NULL;
}

// Default Desctrutor

EmployeeRecord::~EmployeeRecord()
{
  
// It was tested in sprint 1
}

int EmployeeRecord:: getID()
{
cout << " Testing data:" << endl;

   // Testing ID
cout << "Testing getID(). Result = " << m_iEmployeeID << endl;*/
return m_iEmployeeID;

}

void EmployeeRecord::setID(int ID)
{
  
m_iEmployeeID = ID

cout << " Setting data in Record:" << endl;

cout << "ID = " << m_iEmployeeID << endl;*/
}

void EmployeeRecord::getName(char *fName, char *lName)
{
//Copying member variables to parameters for name.

strcpy(fName, m_sFirstName);
strcpy(lName, m_sLastName);
//cout << "Testing getName(). Result = " << m_sFirstName << " " << m_sLastName << endl;

}

void EmployeeRecord::setName(char *fName, char *lName)
{
  
strcpy(m_sFirstName, fName);
strcpy(m_sLastName, lName);

   //cout << "First Name = " << m_sFirstName <    //cout << "Last Name = " << m_sLastName <

}

int EmployeeRecord::getDept()
{
//Copying member variables to parameters for Dept ID
return m_iDeptID;
// testing getDept()
//cout << "Testing getDept(). Result = " << d << endl;
}

void EmployeeRecord::setDept(int d)
{
m_iDeptID = d;
// cout << "Dept = " << m_iDeptID << endl;
}

double EmployeeRecord::getSalary()
{
  
return m_dSalary;
//cout << "Testing getSalary(). Result = " << *sal << endl;
   //cout << endl << endl;

}

void EmployeeRecord::setSalary(double sal)
{
  
m_dSalary = sal;
//cout << "Salary = $" << m_dSalary << " ";
//cout << endl << endl;
}

void EmployeeRecord::printRecord()
{
   // Print out Employee Record
   cout <<"   Print Record " << endl;

cout << "ID: " << m_iEmployeeID << " ";
   cout << " Name: " << m_sLastName << " , " << m_sFirstName << " ";
   cout << " Dept: " << m_iDeptID << " " << " ";
   cout << "Salary: $" << m_dSalary << " " << endl << endl;
}

Explanation / Answer

#include "Store.h"
#include

using namespace std;


// Default Constructor

Store::Store()
{
   m_pNext = NULL;
}


// Constructor

Store::Store(int ID, char *name, char *addr, char *city, char *st, char *zip)
{
   m_iStoreID = ID;
   strcpy(m_sStoreName, name);
   strcpy(m_sAddress, addr);
   strcpy(m_sCity, city);
   strcpy(m_sState, st);
   strcpy(m_sZip, zip);
   m_pNext = NULL;
}


// Destructor

Store::~Store()
{
   // Nothing to do here
}



int Store::getStoreID()
{
   return m_iStoreID;
}


void Store::setStoreID(int ID)
{
   m_iStoreID = ID;
}


char *Store::getStoreName()
{
   char *name = new char[strlen(m_sStoreName) + 1];
   strcpy(name, m_sStoreName);
   return name;
}


void Store::setStoreName(char *name)
{
   strcpy(m_sStoreName, name);
}


char *Store::getStoreAddress()
{
   char *addr = new char[strlen(m_sAddress) + 1];
   strcpy(addr, m_sAddress);
   return addr;
}


void Store::setStoreAddress(char *addr)
{
   strcpy(m_sAddress, addr);
}


char *Store::getStoreCity()
{
   char *city = new char[strlen(m_sCity) + 1];
   strcpy(city, m_sCity);
   return city;
}


void Store::setStoreCity(char *city)
{
   strcpy(m_sCity, city);
}


char *Store::getStoreState()
{
   char *state = new char[strlen(m_sState) + 1];
   strcpy(state, m_sState);
   return state;
}


void Store::setStoreState(char *state)
{
   strcpy(m_sState, state);
}


char *Store::getStoreZip()
{
   char *zip = new char[strlen(m_sZip) + 1];
   strcpy(zip, m_sZip);
   return zip;
}


void Store::setStoreZip(char *zip)
{
   strcpy(m_sZip, zip);
}


void Store::printStoreInfo()
{
   cout << m_iStoreID << setw(20) << m_sStoreName << setw(15) << m_sAddress
       << setw(15) << m_sCity << ", " << m_sState << setw(10) << m_sZip << " ";
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Employee Record header file

--------------------------

#pragma once

#include "CustomerList.h"

class EmployeeRecord
{
private:
int m_iEmployeeID;
char m_sLastName[32];
char m_sFirstName[32];
int m_iDeptID;
double m_dSalary;

public:
           //The default constructor
EmployeeRecord();

           // Constructor shall set the member values passed into the function.
       EmployeeRecord(int ID, char *fName, char *lName, int dept, double sal);

           // The destructor
~EmployeeRecord();

       // shall return the value stored in the member variable
int getID();

       // will set the member variable m_iEmployeeID to the value of its' argument.
void setID(int ID);

       // The getName() function shall copy the member variables m_sFirstName and m_sLastName into the character arrays pointed to by the function arguments.
void getName(char *fName, char *lName);

       // The setName() function will copy the function arguments into the member variables m_sFirstName and m_sLastName
void setName(char *fName, char *lName);

       // The getDept() function shall be defined as a reference function. That is, a call to this function will copy the member variable m_iDeptID into the int variable referenced by the function argument.
int getDept();

           // The setDept() function will copy the function argument into the member variable m_iDeptID.
void setDept(int d);

           // The getSalary() function shall be defined as a pointer function.
double getSalary();

       // The function setSalary() shall copy the function argument into the member variable m_dSalary.
void setSalary(double sal);

       //This function shall print to the screen all data found in the employee's record
void printRecord();

       CustomerList *getCustomerList();
       CustomerList *m_pCustomerList;
};

*****************************************************************************************************************************************************

Employee Record Main

---------------------------------

#include
#include "EmployeeRecord.h"

using namespace std;

//Default Constructor

EmployeeRecord::EmployeeRecord()
{

// The default constructor shall set the member variables to the following
m_iEmployeeID = 0;
m_sFirstName[0] = '';
m_sLastName[0] = '';
m_iDeptID = 0;
m_dSalary = 0.0;
}


EmployeeRecord::EmployeeRecord(int ID, char *fName, char *lName, int dept, double sal)
{

// Copying the member varibles for First and Last name
strcpy(m_sFirstName, fName);
strcpy(m_sLastName, lName);

// Copying other member variables
m_iEmployeeID = ID;
m_iDeptID = dept;
m_dSalary = sal;
fName = NULL;
lName = NULL;
}

// Default Desctrutor

EmployeeRecord::~EmployeeRecord()
{
  
// It was tested in sprint 1
}

int EmployeeRecord:: getID()
{
cout << " Testing data:" << endl;

   // Testing ID
cout << "Testing getID(). Result = " << m_iEmployeeID << endl;*/
return m_iEmployeeID;

}

void EmployeeRecord::setID(int ID)
{
  
m_iEmployeeID = ID

cout << " Setting data in Record:" << endl;

cout << "ID = " << m_iEmployeeID << endl;*/
}

void EmployeeRecord::getName(char *fName, char *lName)
{
//Copying member variables to parameters for name.

strcpy(fName, m_sFirstName);
strcpy(lName, m_sLastName);
//cout << "Testing getName(). Result = " << m_sFirstName << " " << m_sLastName << endl;

}

void EmployeeRecord::setName(char *fName, char *lName)
{
  
strcpy(m_sFirstName, fName);
strcpy(m_sLastName, lName);

   //cout << "First Name = " << m_sFirstName <    //cout << "Last Name = " << m_sLastName <

}

int EmployeeRecord::getDept()
{
//Copying member variables to parameters for Dept ID
return m_iDeptID;
// testing getDept()
//cout << "Testing getDept(). Result = " << d << endl;
}

void EmployeeRecord::setDept(int d)
{
m_iDeptID = d;
// cout << "Dept = " << m_iDeptID << endl;
}

double EmployeeRecord::getSalary()
{
  
return m_dSalary;
//cout << "Testing getSalary(). Result = " << *sal << endl;
   //cout << endl << endl;

}

void EmployeeRecord::setSalary(double sal)
{
  
m_dSalary = sal;
//cout << "Salary = $" << m_dSalary << " ";
//cout << endl << endl;
}

void EmployeeRecord::printRecord()
{
   // Print out Employee Record
   cout <<"   Print Record " << endl;

cout << "ID: " << m_iEmployeeID << " ";
   cout << " Name: " << m_sLastName << " , " << m_sFirstName << " ";
   cout << " Dept: " << m_iDeptID << " " << " ";
   cout << "Salary: $" << m_dSalary << " " << endl << endl;
}

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