I'm attempting to make my class do the following...
EmployeeHandler
: Initializes m_employeeCount to zero.AddEmployee
: Invoked by menu option 1. Displays "NEW EMPLOYEE". Prompts the user for the employee’s first name, last name, and pay rate, one at a time. Uses Employee.Setup to add an employee to m_lstEmployee. Displays "Employee m_employeeCount added". Increments m_employeeCount.EmployeeSelection
: Displays the list of employees, by index; prompts the user for an employee index and returns the index.EditEmployee
: Invoked by menu option 2. Uses EmployeeSelection to get the index of the employee to edit. Verifies if the index is valid and displays an error message if it is not. Uses Employee.Output to display the selected employee’s current information. Prompts the user for the employee’s new first name, last name, and pay rate, one at a time. Uses Employee.Setup to change the employee’s information in m_lstEmployee. Displays “** Employee index updated”, where index is the user selected index.LayoffEmployee
: Invoked by menu option 3. Uses EmployeeSelection to get the index of the employee to lay-off. Uses Employee.Output to display the selected employee’s first name, last name, and pay rate. Uses Employee.LayOff to lay the employee off. Displays "Employee index laid off", where index is laid off employee’s index.DisplayEmployeeList
: Invoked by menu option 4. Displays "EMPLOYEES". Then uses Employee.Output to display every employee record something like this, "[1] David Johnson, PAY: $5.00 (CURRENT EMPLOYEE)" and a former employee record something like this, "[2] David Johnson, PAY: $5.00 (FORMER EMPLOYEE)", where the number in the brackets is the employee’s index in m_lstEmployee.GetEmployee
: Returns the address of the selected employee record in m_lstEmployee.GetEmployeeCount
: Returns the number of employees in m_employeeCount.
So far I have...
#ifndef _EMPLOYEEHANDLER
#define _EMPLOYEEHANDLER
#include "Employee.h"
class EmployeeHandler
{
public:
EmployeeHandler()
{
m_employeeCount = 0; //undefined?
};
void AddEmployee()
{
string firstName;
string lastName;
float payRate;
cout<<"NEW EMPLOYEE"<<endl;
cout<<"First Name:"<<endl;
cin>>firstName;
cout<<"Last Name:"<<endl;
cin>>lastName;
cout<<"Pay Rate:"<<endl;
cin>>payRate;
Employee.Setup(firstName,lastName,payRate); //Problem here
cout<<"**Employee m_employeeCount added"<<endl;
m_employeeCount+=1; //m_employeeCount undefined?
}
void EditEmployee()
{
int indexEdit;
string newFirst;
string newLast;
float newPay;
cout<<"Which employee would you like to edit"<<endl;
cin>>indexEdit;
EmployeeSelection(indexEdit); //undefined?
Employee.Output(); //
cout<<"Employee new first name:"<<endl;
cin>>newFirst;
cout<<"Employee new last name:"<<endl;
cin>>newLast;
cout<<"Employee new pay rate:"<<endl;
cin>>newPay;
Employee.Setup(newFirst,newLast,newPay); ///
cout<<"** Employee index updated"<<endl;
}
void LayoffEmployee()
{
EmployeeSelection();
Employee.Output(EmployeeSelection); //Problems here
Employee.LayOff(EmployeeSelection);
cout<<"Employee laid off"<<endl;
}
void DisplayEmployeeList()
{
cout<<"EMPLOYEES"<<endl;
for (int i=0; i<50; i++)
cout<<[i]<<Employee.Output(m_1stEmployee)<<endl; //
}
int EmployeeSelection()
{
int indexNumber;
for (int i= 0; i <50; i++)
cout<<[i]m_1stEmployee<<endl; //
cout<<"Which Employee Index would you like to select?"<<endl;
cin>>indexNumber;
for (int i = 0; i <50; i++)
if ([i]=indexNumber) //
return [i]
}
Employee& GetEmployee( int index )
{if (index=; // completely confused here
}
int GetEmployeeCount()
{
return m_employeeCount;
};
private:
Employee m_lstEmployee[50];
int m_employeeCount;
};
#endif
The employee.h file is as follows...
#ifndef _EMPLOYEE
#define _EMPLOYEE
#include<iostream>
#include<iomanip>
#include <string>
using namespace std;
class Employee
{
public:
void Setup( const string& first, const string& last, float pay );
{
m_firstName = first;
m_lastName = last;
m_payPerHour = pay;
m_activeEmployee = true;
}
string GetName()
{
return m_firstName+""+m_lastName
};
bool GetIsActive()
{
return m_activeEmployee;
};
void LayOff()
{
m_activeEmployee= false;
};
void Output()
cout<<GetName()<<",PAY:$"<<fixed<<setprecision(2)<<m_payPerHour<<endl;
private:
string m_firstName;
string m_lastName;
float m_payPerHour;
bool m_activeEmployee;
};
#endif
I've been stuck writing this class for the last two days trying to figure out what I'm doing wrong. This is the first time I've attempted to write classes in C++. Any and all help is much, much appreciated. I have marked places where I'm having problems with //
.