Merge branch 'master' of https://git.boerchers.org/CPP/Urlaubsverwaltung
This commit is contained in:
commit
83448701a9
@ -2,9 +2,13 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Class to represent a date.
|
||||||
|
*/
|
||||||
class date
|
class date
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -20,6 +24,10 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get age of current item
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
int get_age() const
|
int get_age() const
|
||||||
{
|
{
|
||||||
time_t timestamp; //Aktuelles Datum und Uhrzeit in Variable speichern
|
time_t timestamp; //Aktuelles Datum und Uhrzeit in Variable speichern
|
||||||
@ -30,9 +38,13 @@ public:
|
|||||||
return current_year - year_;
|
return current_year - year_;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_birthday() const
|
/**
|
||||||
|
* \brief
|
||||||
|
* \return birthday as string.
|
||||||
|
*/
|
||||||
|
string to_string() const
|
||||||
{
|
{
|
||||||
return std::to_string(day_) + "." + to_string(month_) + "." + to_string(year_);
|
return std::to_string(day_) + "." + std::to_string(month_) + "." + std::to_string(year_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,6 +161,7 @@ int main()
|
|||||||
cout << "1: Mitarbeiter anlegen" << endl;
|
cout << "1: Mitarbeiter anlegen" << endl;
|
||||||
cout << "2: Mitarbeiter bearbeiten" << endl;
|
cout << "2: Mitarbeiter bearbeiten" << endl;
|
||||||
cout << "3: Alle Mitarbeiter auflisten" << endl;
|
cout << "3: Alle Mitarbeiter auflisten" << endl;
|
||||||
|
cout << endl;
|
||||||
cout << "0: Programm beenden" << endl;
|
cout << "0: Programm beenden" << endl;
|
||||||
cout << "> ";
|
cout << "> ";
|
||||||
auto input = 0;
|
auto input = 0;
|
||||||
@ -196,8 +209,12 @@ void create_employee()
|
|||||||
unsigned int year;
|
unsigned int year;
|
||||||
cout << "Jahr: ";
|
cout << "Jahr: ";
|
||||||
cin >> year;
|
cin >> year;
|
||||||
employees.emplace_back(name, first_name, day, month, year);
|
auto em = employee(name, first_name, day, month, year);
|
||||||
|
employees.emplace_back(em);
|
||||||
|
cout << "--------------------------------" << endl;
|
||||||
|
print_employee(em);
|
||||||
cout << "Einen weiteren Benutzer eingeben? [J/N]" << endl;
|
cout << "Einen weiteren Benutzer eingeben? [J/N]" << endl;
|
||||||
|
cout << "> ";
|
||||||
string input;
|
string input;
|
||||||
cin >> input;
|
cin >> input;
|
||||||
if (input._Equal("N") || input._Equal("n")) break;
|
if (input._Equal("N") || input._Equal("n")) break;
|
||||||
@ -207,7 +224,7 @@ void create_employee()
|
|||||||
|
|
||||||
employee* search_employee()
|
employee* search_employee()
|
||||||
{
|
{
|
||||||
if (employees.empty()) throw 1;
|
if (employees.empty()) throw exception("Es gibt keine Benutzer in der Datenbank.");
|
||||||
string name;
|
string name;
|
||||||
cout << "Bitte einen Namen eingeben: ";
|
cout << "Bitte einen Namen eingeben: ";
|
||||||
cin >> name;
|
cin >> name;
|
||||||
@ -221,7 +238,7 @@ employee* search_employee()
|
|||||||
return &e;
|
return &e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw 0;
|
throw exception("Benutzer nicht gefunden.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void list_employees()
|
void list_employees()
|
||||||
@ -243,12 +260,14 @@ void modify_employee()
|
|||||||
while (!end_program)
|
while (!end_program)
|
||||||
{
|
{
|
||||||
system("cls");
|
system("cls");
|
||||||
|
cout << "Mitarbeiter:" << endl << endl;
|
||||||
print_employee(*current);
|
print_employee(*current);
|
||||||
cout << "Bitte w\x84hlen Sie eine Option:" << endl;
|
cout << "Bitte w\x84hlen Sie eine Option:" << endl;
|
||||||
cout << "1: Urlaub eingeben" << endl;
|
cout << "1: Urlaub eingeben" << endl;
|
||||||
cout << "2: Mitarbeiter l\x94schen" << endl;
|
cout << "2: Mitarbeiter l\x94schen" << endl;
|
||||||
|
cout << endl;
|
||||||
cout << "0: Zur\x81 \bck" << endl;
|
cout << "0: Zur\x81 \bck" << endl;
|
||||||
cout << "Ihre Eingabe:";
|
cout << "> ";
|
||||||
auto input = 0;
|
auto input = 0;
|
||||||
cin >> input;
|
cin >> input;
|
||||||
|
|
||||||
@ -272,19 +291,9 @@ void modify_employee()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (int ex)
|
catch (exception& ex)
|
||||||
{
|
{
|
||||||
switch (ex)
|
cout << ex.what() << endl;
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
cout << "Benutzer nicht gefunden. Code: " << ex << endl;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
cout << "Es gibt keine Benutzer in der Datenbank. Code: " << ex << endl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
cout << "Unbekannter Fehler. Code: " << ex << endl;
|
|
||||||
}
|
|
||||||
system("pause");
|
system("pause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,7 +301,7 @@ void modify_employee()
|
|||||||
void print_employee(employee 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 << " Geburtstag: " << employee.day_of_birth.to_string() << endl;
|
||||||
cout << " Resturlaub: " << employee.holidays - employee.taken_holidays << endl;
|
cout << " Resturlaub: " << employee.holidays - employee.taken_holidays << endl;
|
||||||
cout << "--------------------------------" << endl;
|
cout << "--------------------------------" << endl;
|
||||||
}
|
}
|
||||||
@ -306,7 +315,7 @@ void enter_holidays(employee& employee)
|
|||||||
cin >> holidays;
|
cin >> holidays;
|
||||||
if (employee.try_take_holidays(holidays))
|
if (employee.try_take_holidays(holidays))
|
||||||
{
|
{
|
||||||
cout << "Urlaub genehmingt." << endl;
|
cout << "Urlaub genehmigt." << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -314,6 +323,7 @@ void enter_holidays(employee& employee)
|
|||||||
}
|
}
|
||||||
cout << "Resturlaub: " << employee.holidays - employee.taken_holidays << " Tage" << endl;
|
cout << "Resturlaub: " << employee.holidays - employee.taken_holidays << " Tage" << endl;
|
||||||
cout << "Einen weiteren Urlaubsantrag eingeben? [J/N]" << endl;
|
cout << "Einen weiteren Urlaubsantrag eingeben? [J/N]" << endl;
|
||||||
|
cout << "> ";
|
||||||
string input;
|
string input;
|
||||||
cin >> input;
|
cin >> input;
|
||||||
if (input._Equal("N") || input._Equal("n")) break;
|
if (input._Equal("N") || input._Equal("n")) break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user