From 3f90260b93792e47f130478c490b9962d204b48a Mon Sep 17 00:00:00 2001 From: Holger Boerchers Date: Tue, 20 Nov 2018 22:37:06 +0100 Subject: [PATCH] bunch of comments --- Urlaubsverwaltung/Urlaubsverwaltung.cpp | 52 +++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/Urlaubsverwaltung/Urlaubsverwaltung.cpp b/Urlaubsverwaltung/Urlaubsverwaltung.cpp index 7cbe81e..856908e 100644 --- a/Urlaubsverwaltung/Urlaubsverwaltung.cpp +++ b/Urlaubsverwaltung/Urlaubsverwaltung.cpp @@ -51,14 +51,22 @@ public: bool operator !=(const date& d) const { return !operator==(d); } }; +/** + * \brief Employee defined with name, first name & date of birth + */ class employee { -private: public: + /** + * \brief Creates a new instance of employee + */ employee(): holidays(0), taken_holidays(0) { } + /** + * \brief Creates a new instance of employee + */ employee(string name, string first_name, short day, short month, unsigned int year) : name(move(name)), first_name(move(first_name)), taken_holidays(0) @@ -68,6 +76,11 @@ public: holidays = age > 50 ? 32 : 30; } + /** + * \brief Try take holidays + * \param days Days to take. + * \return True if holidays ready to take. False otherwise. + */ bool try_take_holidays(const int days) { if (holidays - taken_holidays - days > 0) @@ -78,11 +91,17 @@ public: return false; } + /** + * \brief Implements the equality operator. + */ bool operator ==(const employee& e) const { return name == e.name && first_name == e.first_name && day_of_birth == e.day_of_birth; } + /** + * \brief Implements the inequality operator. + */ bool operator !=(const employee& e) const { return !operator==(e); } string name; @@ -92,12 +111,36 @@ public: int taken_holidays; }; +/** + * \brief Collection of all employees (Database) + */ static list employees; +/** + * \brief Create new employee entry in database. + */ void create_employee(); +/** + * \brief Search employee in the database + * \return Return pointer of type employee + */ employee* search_employee(); +/** + * \brief List all employees in database + */ void list_employees(); +/** + * \brief Modify entry in database + */ void modify_employee(); +/** + * \brief Print information about employee + * \param employee Entry from database. + */ void print_employee(employee employee); +/** + * \brief Enter holidays to take, if available. + * \param employee Employee as reference. + */ void enter_holidays(employee& employee); int main() @@ -135,6 +178,7 @@ int main() system("pause"); } } + return 0; } void create_employee() @@ -208,7 +252,7 @@ void modify_employee() cout << "Bitte w\x84hlen Sie eine Option:" << endl; cout << "1: Urlaub eingeben" << endl; cout << "2: Mitarbeiter l\x94schen" << endl; - cout << "0: Zurueck" << endl; + cout << "0: Zur\x81 \bck" << endl; cout << "Ihre Eingabe:"; auto input = 0; cin >> input; @@ -252,9 +296,9 @@ void modify_employee() void print_employee(employee employee) { - cout << " " << employee.first_name << employee.name << endl; + cout << " " << employee.first_name << " " << employee.name << endl; cout << " Geburtstag: " << employee.day_of_birth.get_birthday() << endl; - cout << " Urlaub: " << employee.holidays << " Genehmigter Urlaub: " << employee.taken_holidays << endl; + cout << " Resturlaub: " << employee.holidays - employee.taken_holidays << endl; cout << "--------------------------------" << endl; }