-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.cpp
More file actions
48 lines (40 loc) · 1.01 KB
/
Employee.cpp
File metadata and controls
48 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Class implementation of the Employee class.
#include <iostream>
#include <string>
#include "Employee.h"
using namespace std;
// class constructor
Employee::Employee(string givenFirstName, string givenLastName, int givenSalary){
setFirstName(givenFirstName);
setLastName(givenLastName);
setSalary(givenSalary);
}
// get function for firstName
string Employee::getFirstName(){
return firstName;
}
// set function for firstName
void Employee::setFirstName(string givenFirstName){
firstName = givenFirstName;
}
// get function for lastName
string Employee::getLastName(){
return lastName;
}
// set function for lastName
void Employee::setLastName(string givenLastName){
lastName = givenLastName;
}
// get function for salary
int Employee::getSalary(){
return salary;
}
// set function for salary
void Employee::setSalary(int givenSalary){
if (givenSalary <= 0){
cerr << "Invalid salary. Setting to 0." << endl;
salary = 0;
}else {
salary = givenSalary;
}
}