1
0

added date class

This commit is contained in:
Holger Börchers 2018-11-04 21:00:16 +01:00
parent 593525e53c
commit 5a44a57bee

View File

@ -1,42 +1,56 @@
#include "pch.h" #include "pch.h"
#include <iostream> #include <iostream>
#include <ctime> #include <ctime>
#include <utility>
#include <vector> #include <vector>
#include <list> #include <list>
#include <string> #include <string>
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 class Employee
{ {
private: private:
public: 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 = Date(day, month, year);
day_of_birth.tm_mon = month - 1; holidays = 30;
day_of_birth.tm_year = year - 1900;
} }
string name; string name;
string first_name; string first_name;
tm day_of_birth; Date day_of_birth;
int holidays; int holidays;
int taken_holidays; int taken_holidays;
}; };
static list<Employee> employees; static list<Employee> employees;
void CreateEmployee(); void create_employee();
int main() int main()
{ {
bool end_program = false; auto end_program = false;
while (!end_program) while (!end_program)
{ {
int input = 1;
system("cls"); system("cls");
cout << "Urlaubsverwaltung" << endl << endl; cout << "Urlaubsverwaltung" << endl << endl;
cout << "Bitte wählen Sie eine Option:" << endl; cout << "Bitte wählen Sie eine Option:" << endl;
@ -46,12 +60,14 @@ int main()
cout << "4: Mitarbeiter suchen" << endl; cout << "4: Mitarbeiter suchen" << endl;
cout << "5: Alle Mitarbeiter auflisten" << endl; cout << "5: Alle Mitarbeiter auflisten" << endl;
cout << "0: Programm beenden" << endl; cout << "0: Programm beenden" << endl;
cout << "ihre Eingabe:";
auto input = 0;
cin >> input; cin >> input;
switch (input) switch (input)
{ {
case 1: case 1:
CreateEmployee(); create_employee();
break; break;
case 2: case 2:
break; break;
@ -66,33 +82,35 @@ int main()
break; break;
default: default:
cout << "Unerlaubte Eingabe" << endl; cout << "Unerlaubte Eingabe" << endl;
system("pause");
} }
} }
} }
void CreateEmployee() void create_employee()
{ {
string name; while (true)
string first_name; {
cout << "Bitte einen Namen eingeben: "; string name;
cin >> name; string first_name;
cout << endl; cout << "Bitte einen Namen eingeben: ";
cout << "Bitte einen Vornamen eingeben: "; cin >> name;
cin >> first_name; cout << "Bitte einen Vornamen eingeben: ";
cout << endl; cin >> first_name;
cout << "Bitte das Geburtsdatum eingeben: " << endl; cout << "Bitte das Geburtsdatum eingeben: " << endl;
int day; short day;
cout << "Tag: "; cout << "Tag: ";
cin >> day; cin >> day;
int month; short month;
cout << "Monat: "; cout << "Monat: ";
cin >> month; cin >> month;
int year; unsigned int year;
cout << "Jahr: "; cout << "Jahr: ";
cin >> year; cin >> year;
employees.emplace_back(name, first_name, day, month, year);
Employee em = Employee(name, first_name, day, month, year); cout << "Einen weiteren Benutzer eingeben? [J/N]" << endl;
string input;
//employees.push_back() cin >> input;
if (input._Equal("N")|| input._Equal("n")) break;
}
} }