1
0

added hot methods

This commit is contained in:
Holger Börchers 2018-11-18 22:34:13 +01:00
parent 412344a635
commit 8ef88ad505

View File

@ -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, &timestamp);
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<employee> 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)