From 8ef88ad505f0b882fc5325d7b34bbb3e22a69e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20B=C3=B6rchers?= Date: Sun, 18 Nov 2018 22:34:13 +0100 Subject: [PATCH 1/2] added hot methods --- Urlaubsverwaltung/Urlaubsverwaltung.cpp | 63 ++++++++++++++++++------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/Urlaubsverwaltung/Urlaubsverwaltung.cpp b/Urlaubsverwaltung/Urlaubsverwaltung.cpp index cf92491..6a757f5 100644 --- a/Urlaubsverwaltung/Urlaubsverwaltung.cpp +++ b/Urlaubsverwaltung/Urlaubsverwaltung.cpp @@ -8,6 +8,16 @@ using namespace std; +//Zeichen Hex Okt +//======================== +// 'Ä' 8E 216 +// 'ä' 84 204 +// 'Ö' 99 231 +// 'ö' 94 224 +// 'Ü' 9A 232 +// 'ü' 81 201 +// 'ß' E1 341 + class Date { private: @@ -23,15 +33,19 @@ public: { } - double get_age() const + int get_age() const { - tm new_time{}; - __time64_t long_time; - _time64(&long_time); - const auto err = _localtime64_s(&new_time, &long_time); - if (!err) return new_time.tm_year - (year - 1900) - 1; - printf("Invalid argument to _localtime_s"); - return 0; + time_t timestamp; //Aktuelles Datum und Uhrzeit in Variable speichern + timestamp = time(nullptr); + tm date{}; + localtime_s(&date, ×tamp); + const auto current_year = date.tm_year + 1900; + return current_year - year; + } + + string get_birthday() const + { + return std::to_string(day) + "." + to_string(month) + "." + to_string(year); } }; @@ -80,7 +94,9 @@ static list employees; void create_employee(); -void search_employee(); +employee search_employee(); + +void list_employees(); int main() { @@ -89,9 +105,9 @@ int main() { system("cls"); cout << "Urlaubsverwaltung (" << employees.size() << " Mitarbeiter)" << endl << endl; - cout << "Bitte wählen Sie eine Option:" << endl; + cout << "Bitte w\x84hlen Sie eine Option:" << endl; cout << "1: Mitarbeiter anlegen" << endl; - cout << "2: Mitarbeiter löschen" << endl; + cout << "2: Mitarbeiter l\x94schen" << endl; cout << "3: Urlaub eingeben" << endl; cout << "4: Mitarbeiter suchen" << endl; cout << "5: Alle Mitarbeiter auflisten" << endl; @@ -113,6 +129,7 @@ int main() search_employee(); break; case 5: + list_employees(); break; case 0: end_program = true; @@ -122,7 +139,7 @@ int main() system("pause"); } } -} +} void create_employee() { @@ -154,7 +171,7 @@ void create_employee() void modify_employee(employee employee); -void search_employee() +employee search_employee() { string name; cout << "Bitte einen Namen eingeben: "; @@ -162,17 +179,27 @@ void search_employee() string first_name; cout << "Bitte einen Vornamen eingeben: "; cin >> first_name; - const auto found = employee(); for (auto e : employees) { if (e.first_name._Equal(first_name) && e.name._Equal(name)) { - found = const employee(e); - break; + return e; } } - modify_employee(found); - employees.remove(const found); + return employee{}; +} + + +void list_employees() +{ + for (const auto& employee : employees) + { + cout << " First name: " << employee.first_name << " Name: " << employee.name << endl; + cout << " Birthday: " << employee.day_of_birth.get_birthday() << endl; + cout << " Holidays: " << employee.holidays << " Taken Holidays: " << employee.taken_holidays << endl; + cout << "--------------------------------" << endl; + } + system("pause"); } void modify_employee(employee employee) From 1460e820ee11b5e7e933882d8f627999e4a2a1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20B=C3=B6rchers?= Date: Sun, 18 Nov 2018 22:37:33 +0100 Subject: [PATCH 2/2] Do not use precompiled header --- Urlaubsverwaltung/Urlaubsverwaltung.cpp | 1 - Urlaubsverwaltung/Urlaubsverwaltung.vcxproj | 11 +---------- Urlaubsverwaltung/Urlaubsverwaltung.vcxproj.filters | 8 -------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Urlaubsverwaltung/Urlaubsverwaltung.cpp b/Urlaubsverwaltung/Urlaubsverwaltung.cpp index 6a757f5..4c8a5f9 100644 --- a/Urlaubsverwaltung/Urlaubsverwaltung.cpp +++ b/Urlaubsverwaltung/Urlaubsverwaltung.cpp @@ -1,4 +1,3 @@ -#include "pch.h" #include #include #include diff --git a/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj b/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj index b26ec53..34a23db 100644 --- a/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj +++ b/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj @@ -99,7 +99,7 @@ - Use + NotUsing Level3 Disabled true @@ -151,15 +151,6 @@ - - - - - Create - Create - Create - Create - diff --git a/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj.filters b/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj.filters index c4fb352..656c6dc 100644 --- a/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj.filters +++ b/Urlaubsverwaltung/Urlaubsverwaltung.vcxproj.filters @@ -15,14 +15,6 @@ - - Headerdateien - - - - - Quelldateien - Quelldateien