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