Define a class EmployeeList that has the following data members: . An array that
ID: 3699478 • Letter: D
Question
Define a class EmployeeList that has the following data members: . An array that holds a list of employee objects. · an integer that stores the number of employee objects in the list. e a default constructor. . a member function that adds an employee object to the list. The function should have the The class should have the following member functions and operations: employee object as a parameter and bool as the return type. It should check if the list has more space to hold an additional employee. The function should also forbidden a same object to be added to the database. If the function can add additional employee, it returns true; otherwise it returns false. member function that deletes an employee data from the list. The function should have an employee object as a parameter and bool as a return type. It should check if the list is empty. If so, the fumtion returns false. Otherwise it checks to see this employee is in the list ( using operators.= & != on Employee objects). If not, it returns false again. Otherwise the function deletes this employee and return true. a member function that searches for an employee in the list according to the id as a parameter and returns the index of the employee if it is in the list Othenwise it returns a negative value to indicate the employee is not in the list provided , , a member function that modifies an employee s data according to the location (index) sn the list. The function should have the index as a parameter It should ask the user which data member to be modified For example, the output of this function might look likeExplanation / Answer
#include <iostream>
class Employee {
}
class EmployeeList {
public:
// Creating an Array of Size 20
//Assuming the max. number of employees is 20
vector <Employee> employeeList(20);
int numEmployees;
void EmployeeList(){
numEmployees=0;
}
bool addEmployee(Employee emp) {
int i; //Checking if the list is full
if(employeeList.size()==20) {
return false;
} //checking if the employee already exists
for(i=0;i<employeeList[i].size();i++) {
if(emp.id==employeeList[i].id) {
return false;
}
}// adding the employee
employeeList.pushback(emp);
return true;
}
bool delEmployee(Employee emp) {
//Checking if the list is empty
if(employeeList.empty()) {
return false;
}
int i; //finding the position of the employee
for(i=0;i<employeeList.size();i++) {
if(emp.id==employeeList[i].id) {
break;
}
}//Deleting the Employee
employeeList.erase(i);
return true;
}
int searchEmployee(int id) {
//Checking if the list is empty
if(employeeList.empty()) {
return -1;
}
int i; //finding the position of the employee
for(i=0;i<employeeList.size();i++) {
if(id==employeeList[i].id) {
break;
}
}
return i;
}
void modifyEmployee(int i) {
//Now, as the variables in the Employee class are not mentioned in the question
//According to the function the object to be modified is "employeeList[i]"
}
}
int main() {
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.