-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.h
314 lines (228 loc) · 6.45 KB
/
functions.h
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
//#pragma once
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <iostream>
#include <string>
#include <map>
#include <fstream>
using namespace std;
// Books struct declaration
struct Books {
string title{},author{}, publisher{},subject{}, ISBN{},WorldCat{};
double DeweyDecimal{};
int pubYear{ 0 }, acqYear{0},currStock{0};
// The following constructor and destructors are useless since they implicitely defined already by the compiler
Books();
~Books();
};
struct Officer {
string fullName{};
string position{};
char sex{};
int age{};
string race{};
//want to make the default constructor or destructor explicitly visible for documentation purposes.
Officer() {
}
~Officer() {
}
};
class User {
public:
string firstName;
string lastName;
int Age;
string Email;
// Default constructor
User() {
firstName = "";
lastName = "";
Age = 10;
Email = "";
}
// Params constructor
User(string& fname, string& lname, int age, string& email) : firstName(fname), lastName(lname), Age(
age), Email(email){}
User(string fname, string lname, int age) {
firstName = fname;
lastName = lname;
Age = age;
Email = fname + "." + lname + "@gmail.com";
}
};
Books& inPopulate(Books& bookTemplate); //Should be able to use one for both DNRY, with medium being a parameter
Books& populate(Books& bookTemplate);
string getNextLine(ifstream& inFile);
void mPopulate(Officer& officer);
void writeFile(map < string, Officer> & staff, ofstream& outFile);
void function1();
void function2();
void printUser(User u);
class Stadium {
string name;
int capacity;
string location;
int minCapacity() {
return capacity / 2;
}
public:
int maxCapacity() {
return capacity * 2; // Because maxCapacity() is a member of the function but not private, this has to be used to access private member
}
Stadium(string n, int c, string l) {
name = n;
capacity = c;
location = l;
}
int minimumCapacity(void) {
return minCapacity();
}
string& getName() {
return name;
}
void setName(string& n) {
this->name = n;
}
};
class Vehicle {
string type;
string tyresNum;
string engineCapacity;
protected:
string engineType;
void setTyresNum(string tyrNum) { tyresNum = tyrNum; }
void setEngineCapacity(string engCap) { engineCapacity = engCap; }
public:
string getType() {
return type;
} // May be used while writing to a file
void setType(string type) { this->type = type; } // Creating access to private member can be done at Protected (accessible to inherited class) or Public (Accessible to everyone)
string countryOrigin;
Vehicle() {};
Vehicle(string t, string tyre, string eng, string engType) {
type = t;
tyresNum = tyre;
engineCapacity = eng;
engineType = engType;
}
};
// ~region Car class declaration
class Car : public Vehicle {
public:
string make;
string model;
Car(string typ, string tyrNum, string egCap, string engTyp, string country, string mk, string mdl);
string sounds(string vehicleType);
};
// #end of region
// Plant Declaration
class Plant {
public:
string plantName{}, plantType{}, tyreType{}, maneuvCapability, roughCapability;
Plant();
~Plant();
};
// Base class
class Employee {
protected:
string ID;
string name;
int age;
string sex;
string address;
string position;
int salary;
public:
//Constructor declaration
Employee(const string& empId, const string& empName, int empAge, const string& empSex,
const string& empAddress, const string& empPosition, const int empSalary);
// Getters declaration
string& getID();
string& getName();
int getAge();
string& getSex();
string& getAddress();
string& getPosition();
int getSalary();
// Setters declaration
void setID(const string& empId);
void setName(const string& empName);
void setAge(int empAge);
void setSex(const string& empSex);
void setAddress(const string& empAddress);
void setPosition(const string& empPosition);
void setSalary(const int empSalary);
// Print Employee data to the screen
virtual void displayInfo();
//Calculate Annual Salary
int annualSalary(int monthlySalary);
//Update residential address..............to be implemented later
~Employee();
};
// Derived class linking with base class
class Manager : public Employee {
string m_officialCar;
string m_officialResidence;
public:
// Constructor with using the initialization list of the parent Employee
Manager(const string& manID, const string& manName, const int manAge, const string& manSex, const string& manAddress, const string& manPosition,
const int manSalary, const string& m_officialCar, const string& m_officialResidence);
// Getters
string& getOfficialCar();
string& getOfficialResidence();
//Setters
void setOfficialCar(string& officialCar);
void setOfficialResidence(string& officialResidence);
// Fucntion to display manager content including employee
void displayInfo() override;
//Conduct meeting
//Manager Destructor declaration
~Manager();
};
//Another derived class on Employee
class Director : public Manager {
int m_budget = 0;
string m_region;
string m_strategicGoal;
public:
Director(const string& dirID, const string& dirName, const int dirAge, const string& dirSex, const string& dirAddress, const string& dirPosition,
const int dirSalary, const string& dirOfficialCar, const string& dirOfficialResidence, const int dirBudget, const string& dirRegion,
const string& dirStrategicGoal);
void displayInfo() override;
//Director Setters
void setBudget(int budget) { m_budget = budget; }
void setRegion(string& region) { m_region = region; }
void setStrategicGoal(string& goal) { m_strategicGoal = goal; }
//Director Getters
int getBudget() { return m_budget; }
string& getRegion() { return m_region; }
string& getStrategicGoal() { return m_strategicGoal; }
//Director Destructor Declaration
~Director();
};
// FIle processing declaration
template <class T>
void fileProcessing(string& m_fileLocation, T& m_staff) {
ofstream outFile;
outFile.open(m_fileLocation, ios::app);
if (!outFile.is_open()) {
cout << "*** File opened unsuccessfully ***\n";
}
else
{
writeToFile(outFile, m_staff);
outFile.close();
cout << "\n\n*** Staff record written to file successfully ***\n";
}
}
void writeToFile(ofstream& outFile, Employee& employee);
void writeToFile(ofstream& outFile, Manager& manager);
void writeToFile(ofstream& outFile, Director& director);
/*
TO DO NEXT
Namespace to be streamlined
Classes to be expanded
Functions to be reviewed to include map
Entered data to be printed to a file
*/
#endif // FUNCTIONS_H