Hi I'm a beginner and I need some help with designing this program. It basically asks to make a class named Employee that has these variables: Name, Id Number, Department and Position.
The class should have these constructors:
1- A constructor that accepts the arguments: Employee Name, Id Number, Department and Position. Then assigns them to their member variables.
2-A constructor that accepts these values as arguments then assigns them to their member variables:Employee name, Id Number.The department and position should be assigned an empty string("").
3- A default constructor that assigns empty strings("") to the name, department and position member variables, and ) to the Id number member variable.
After that I'm supposed ask the user to enter the Employee name, Id Number,Department and Position for three employees and store it in three objects then display the data for eah employee on the screen.
So far this is what I have :
#include <iostream>
using namespace std;
class Employee
{
private:
string Name;
int IdNumber;
string Department;
string Position;
public:
Employee(string AssignName,int AssignIdNumber,string AssignDepartment,string AssignPosition)
{
Name=AssignName;
IdNumber=AssignIdNumber;
Department=AssignDepartment;
Position=AssignPosition;
}
Employee(string AssignName,int AssignIdNumber)
{
Name=AssignName;
IdNumber= AssignIdNumber;
Department="";
Position="";
}
Employee()
{
Name="";
IdNumber=0;
Department="";
Position="";
}
void setName(string);
void setIdNumber(int);
void setDepartment(string);
void setPosition(string);
string getName() const;
int getIdNumber() const;
string getDepartment() const;
string getPosition () const;
};
void Employee::setName(string N)
{
Name = N;
}
void Employee::setIdNumber(int ID)
{
IdNumber = ID;
}
void Employee::setDepartment(string Depart)
{
Department = Depart;
}
void Employee::setPosition (string Pos)
{
Position = pos;
}
string Employee::getName() const
{
return Name;
}
int Employee::getIdNumber() const
{
return IdNumber;
}
string Employee::getDepartment() const
{
return Department;
}
string Employee::getPosition() const
{
return Position;
}
int main()
{
Employee info;
string EmployeeName;
int EmployeeIdNumber;
string EmployeeDepartment;
string EmployeePosition;
//Get info from the use
cout<<"What is the Employee's Name?";
cin>>EmployeeName;
cout<<"What is the Employee's Id Number?";
cin>>EmployeeIdNumber;
cout<<"What is the Employee's Department?";
cin>>EmployeeDepartment;
cout<<"What is the Employee's position?";
cin>>EmployeePosition;
//Store information in the info object
info.setName(EmployeeName);
info.setIdNumber(EmployeeIdNumber);
info.setDepartment(EmployeeDepartment);
info.setPosition(EmployeePosition);
//Display Employee Data
cout<<"Here's the employee's data:\n";
cout<<"Name: "<<info.getName()<<endl;
cout<<"Id Number: "<<info.getIdNumber()<<endl;
cout<<"Department: "<<info.getDepartment()<<endl;
cout<<"Position: "<<info.getPosition()<<endl;
return 0;
}
First of all This has been kind of hard for me to comprehend but I tried my best and this is all I have. I don't know how to process each employee's data correctly...Please help I'm very desperate