Home Employee class C++ inputting the information.
Reply: 0

Employee class C++ inputting the information.

user3358
1#
user3358 Published in April 25, 2018, 12:43 am
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

class Employee {
private:
    string employee_firstname;
    string employee_lastname;
    string idnumber;
    string address;
    string phonenumber;
    string tenure;

public:
    Employee() {
        employee_firstname = "";
        employee_lastname = "";
        idnumber = "";
        address = "";
        phonenumber = "";
        tenure = "0";
    }
    Employee(string fn, string ln, string id, string ad, string ph, string ten) {
        employee_firstname = fn;
        employee_lastname = ln;
        idnumber = id;
        address = ad;
        phonenumber = ph;
        tenure = ten;


    }
    string getFirstName();
    string getLastName();
    string getidnumber();
    string getAddress();
    string getPhone();
    string getTenure();

    void setFirstname(string fn) {
        employee_firstname = fn;
    }
    void setLastname(string ln) {
        employee_lastname = ln;
    }
    void setidnumber(string id) {
        idnumber = id;
    }
    void setaddress(string ad) {
        address = ad;
    }
    void setphonenumber(string ph) {
        phonenumber = ph;
    }
    void settenure(string ten) {
        tenure = ten;
    }
};
string Employee::getFirstName() {
    return employee_firstname;
}
string Employee::getLastName() {
    return employee_lastname;
}
string Employee::getidnumber() {
    return idnumber;
}
string Employee::getAddress() {
    return address;
}
string Employee::getPhone()
{
    return phonenumber;
}
string Employee::getTenure() {
    return tenure;
}

const int employee_num = 3;

int main()
{
    Employee num[employee_num] = {
        ("John", "Smith", 4752, "8971 herlo st", "916-628-8452", 8),
        ("Cathy", "Guringo", 5826, "538 reed ct", "310-852-6654", 5),
        ("Kyle", "Ford", 7856, "292 murrietta st", "323-547-7423", 3),
    };

    for (int i = 0; i < employee_num; i++)
    {
        cout << num[i].getFirstName() << " ";
        cout << num[i].getLastName() << " ";
        cout << num[i].getidnumber() << " ";
        cout << num[i].getAddress() << " ";
        cout << num[i].getPhone() << " ";
        cout << num[i].getTenure() << " ";
    }
    return 0;
}

I'll be completely honest. I don't understand how to retrieve and display the employee's information here. I've asked the professor and the way he explains it doesn't really make sense to me. He can't really explain it in a different way.

The prompt from my professor goes like this:

Write a Employee class that contains the following fields:

  • Last Name
  • First Name
  • Employee ID
  • Address
  • Phone Number
  • Years Employed

The class should have two constructors: - A default constructor that sets the fields to empty strings ("") and 0 for years employed - A constructor that accepts the three fields as arguments and assigns them to Last Name, First Name, and Employee ID.

Write appropriate mutator methods to store values in the fields and accessor methods to return the values in the fields.

In the main function, create three Employee objects by entering the fields for each object from the keyboard.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298713 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO