From 5a44a57bee10ffd68326ead529ddb4c35a1df41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20B=C3=B6rchers?= Date: Sun, 4 Nov 2018 21:00:16 +0100 Subject: [PATCH] added date class --- Urlaubsverwaltung/Urlaubsverwaltung.cpp | 92 +++++++++++++++---------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/Urlaubsverwaltung/Urlaubsverwaltung.cpp b/Urlaubsverwaltung/Urlaubsverwaltung.cpp index 5f0c6f1..c337a17 100644 --- a/Urlaubsverwaltung/Urlaubsverwaltung.cpp +++ b/Urlaubsverwaltung/Urlaubsverwaltung.cpp @@ -1,42 +1,56 @@ #include "pch.h" #include #include +#include #include #include #include -using namespace std; +using namespace std; + +class Date +{ +private: + short day; + short month; + unsigned int year; +public: + Date() : day(1), month(1), year(1900) + { + + } + Date(short day, short month, unsigned int year) : day(day), month(month), year(year) + { + } +}; + class Employee { private: public: - Employee(string a_name, string a_first_name, int day, int month, int year) : name(a_name), first_name(a_first_name) + Employee(string name, string first_name, short day, short month, unsigned int year) : name(move(name)), first_name(move(first_name)), taken_holidays(0) { - day_of_birth.tm_mday = day; - day_of_birth.tm_mon = month - 1; - day_of_birth.tm_year = year - 1900; - + day_of_birth = Date(day, month, year); + holidays = 30; } + string name; string first_name; - tm day_of_birth; + Date day_of_birth; int holidays; int taken_holidays; - - }; static list employees; -void CreateEmployee(); +void create_employee(); int main() { - bool end_program = false; + auto end_program = false; while (!end_program) { - int input = 1; system("cls"); cout << "Urlaubsverwaltung" << endl << endl; cout << "Bitte wählen Sie eine Option:" << endl; @@ -46,12 +60,14 @@ int main() cout << "4: Mitarbeiter suchen" << endl; cout << "5: Alle Mitarbeiter auflisten" << endl; cout << "0: Programm beenden" << endl; + cout << "ihre Eingabe:"; + auto input = 0; cin >> input; switch (input) { case 1: - CreateEmployee(); + create_employee(); break; case 2: break; @@ -66,33 +82,35 @@ int main() break; default: cout << "Unerlaubte Eingabe" << endl; - + system("pause"); } } } -void CreateEmployee() +void create_employee() { - string name; - string first_name; - cout << "Bitte einen Namen eingeben: "; - cin >> name; - cout << endl; - cout << "Bitte einen Vornamen eingeben: "; - cin >> first_name; - cout << endl; - cout << "Bitte das Geburtsdatum eingeben: " << endl; - int day; - cout << "Tag: "; - cin >> day; - int month; - cout << "Monat: "; - cin >> month; - int year; - cout << "Jahr: "; - cin >> year; - - Employee em = Employee(name, first_name, day, month, year); - - //employees.push_back() + while (true) + { + string name; + string first_name; + cout << "Bitte einen Namen eingeben: "; + cin >> name; + cout << "Bitte einen Vornamen eingeben: "; + cin >> first_name; + cout << "Bitte das Geburtsdatum eingeben: " << endl; + short day; + cout << "Tag: "; + cin >> day; + short month; + cout << "Monat: "; + cin >> month; + unsigned int year; + cout << "Jahr: "; + cin >> year; + employees.emplace_back(name, first_name, day, month, year); + cout << "Einen weiteren Benutzer eingeben? [J/N]" << endl; + string input; + cin >> input; + if (input._Equal("N")|| input._Equal("n")) break; + } }