Need Help With Classes/Vectors

I am currently working on a class project and am having difficulties figuring out how to properly execute my code and what to include into main.cpp. I am to create a vector of employees (ability to add/remove them), create an office directory, and include estimated burn rate. I have included the more specific instructions in the comments of my "Office.h" file. Here is what I have so far:

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

Employee.cpp:

#include "Employee.h"

void Employee::SetName(std::string n)
{
name = n;
}
std::string Employee::GetName()
{
return name;
}
void Employee::SetID(std::string i)
{
id = i;
}
std::string Employee::GetID()
{
return id;
}
void Employee::SetWage(const double w)
{
if (w < 0.0)
wage = 0.0;
else
wage = w;
}
double Employee::GetWage() const
{
return wage;
}

void Employee::SetYear(const int y)
{
if (y < 2003)
year = 2003;
else if (y > 2018)
year = 2018;
else
year = y;
}

int Employee::GetYear() const
{
return year;
}

Employee.h:

#pragma once
#include <string>

class Employee
{
private:
std::string name;
std::string id;
double wage;
int year;

public:
void SetName(std::string);
std::string GetName();
void SetID(std::string);
std::string GetID();
void SetWage(const double);
double GetWage() const;
void SetYear(int);
int GetYear() const;
};

Office.h:


#pragma once
#include <string>

/*vector of employees <type>
Employee
--------------
Add Employee
Remove Employee

Office
-------------
Office Directory
	-Add Employee
	-List Active Employees
	-Remove an Active Employee
	-Quit

Estimate Burn Rate - monthly  wages*40*4 (may have to modify employee class)
OfficePeoplePower estimated in hours per Month - show me how many hrs I can schedule of work per month



Main
--------------
Implement classes

*/
class Office 
{
private:
	std::string companyName;
	
public:
	Office();
	Office(std::string);

};


Office.cpp:


#include "Office.h"

Office::Office()
{
	companyName = "";

}

Office::Office(std::string companyName)
{
	//this
	this->companyName = companyName;

}



I am to create a vector of employees (ability to add/remove them), create an office directory, and include estimated burn rate.
From an Object Oriented Design perspective, OfficeDirectory is associated with a collection of Employee. BurnRate is a calculation of some sort. You'd need to specify what the calculation is to yield that value to know exactly what to do with it.

In code, you might define your objects as:
1
2
3
4
5
6
7
8
9
10
11
12
class Employee
{
//...
};

typedef std::vector<Employee> Employees;

class OfficeDirectory
{
    Employees m_employees;
    //...
};


In my view, you shouldn't add getters/setters. Decide what operations you need on an object and provide methods to support them. Just because your object has a member, m_firstname doens't mean you should automatically have methods getFirstName() / setFirstName(). Objects are not records.
Topic archived. No new replies allowed.