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; using namespace std;
//Zeichen Hex Okt
//========================
// 'Ä' 8E 216
// 'ä' 84 204
// 'Ö' 99 231
// 'ö' 94 224
// 'Ü' 9A 232
// 'ü' 81 201
// 'ß' E1 341
class Date class Date
{ {
private: private:
@ -23,15 +33,19 @@ public:
{ {
} }
double get_age() const int get_age() const
{ {
tm new_time{}; time_t timestamp; //Aktuelles Datum und Uhrzeit in Variable speichern
__time64_t long_time; timestamp = time(nullptr);
_time64(&long_time); tm date{};
const auto err = _localtime64_s(&new_time, &long_time); localtime_s(&date, &timestamp);
if (!err) return new_time.tm_year - (year - 1900) - 1; const auto current_year = date.tm_year + 1900;
printf("Invalid argument to _localtime_s"); return current_year - year;
return 0; }
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 create_employee();
void search_employee(); employee search_employee();
void list_employees();
int main() int main()
{ {
@ -89,9 +105,9 @@ int main()
{ {
system("cls"); system("cls");
cout << "Urlaubsverwaltung (" << employees.size() << " Mitarbeiter)" << endl << endl; 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 << "1: Mitarbeiter anlegen" << endl;
cout << "2: Mitarbeiter löschen" << endl; cout << "2: Mitarbeiter l\x94schen" << endl;
cout << "3: Urlaub eingeben" << endl; cout << "3: Urlaub eingeben" << endl;
cout << "4: Mitarbeiter suchen" << endl; cout << "4: Mitarbeiter suchen" << endl;
cout << "5: Alle Mitarbeiter auflisten" << endl; cout << "5: Alle Mitarbeiter auflisten" << endl;
@ -113,6 +129,7 @@ int main()
search_employee(); search_employee();
break; break;
case 5: case 5:
list_employees();
break; break;
case 0: case 0:
end_program = true; end_program = true;
@ -122,7 +139,7 @@ int main()
system("pause"); system("pause");
} }
} }
} }
void create_employee() void create_employee()
{ {
@ -154,7 +171,7 @@ void create_employee()
void modify_employee(employee employee); void modify_employee(employee employee);
void search_employee() employee search_employee()
{ {
string name; string name;
cout << "Bitte einen Namen eingeben: "; cout << "Bitte einen Namen eingeben: ";
@ -162,17 +179,27 @@ void search_employee()
string first_name; string first_name;
cout << "Bitte einen Vornamen eingeben: "; cout << "Bitte einen Vornamen eingeben: ";
cin >> first_name; cin >> first_name;
const auto found = employee();
for (auto e : employees) for (auto e : employees)
{ {
if (e.first_name._Equal(first_name) && e.name._Equal(name)) if (e.first_name._Equal(first_name) && e.name._Equal(name))
{ {
found = const employee(e); return e;
break;
} }
} }
modify_employee(found); return employee{};
employees.remove(const found); }
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) void modify_employee(employee employee)