Question
In the below code Add a main menu to manage the employees data, which will include a choice of: 1) Access employee record based on
In the below code Add a main menu to manage the employees data, which will include a choice of: 1) Access employee record based on employee ID only (can be the index of the array, you may not to perform a search, this is called Hashing 2) Add an employee to the database 3) Delete an employee (delete the index), if an ID is available use it for the new employee #include
// Employee Class Declaration
class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position
public: // Constructors Employee(string, int, string, string); Employee();
// update methods void setName(string n) { name = n; }
void setIdNumber(int i) { idNumber = i; }
void setDepartment(string d) { department = d; }
void setPosition(string p) { position = p; }
// Accessors string getName() { return name; }
int getIdNumber() { return idNumber; }
string getDepartment() { return department; }
string getPosition() { return position; } };
// Constructor #1 Employee::Employee(string n, int i, string d, string p) { name = n; idNumber = i; department = d; position = p; }
// Constructor #3, default constructor Employee::Employee() { name = ""; idNumber = 0; department = ""; position = ""; }
// Function prototype void displayEmployee(Employee);
// Driver program to demonstrate the class int main() { // Create an Employee object based on the current constructor. Employee Albert("Albert Smith", 1, "Executive", "President");
Employee employees[10];
// Display each employee's data. displayEmployee(Albert); displayEmployee(employees[2]);
return 0; }
//************************************************** // The displayEmployee function displays the data * // in the Employee object passed as an argument. * //**************************************************
void displayEmployee(Employee e) { cout << "Name: " << e.getName() << endl; cout << "ID Number: " << e.getIdNumber() << endl; cout << "Department: " << e.getDepartment() << endl; cout << "Position: " << e.getPosition() << endl << endl; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started