Compare commits
2 Commits
1460e820ee
...
0040965d2f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0040965d2f | ||
![]() |
3c4e1056e3 |
@ -20,15 +20,15 @@ using namespace std;
|
|||||||
class Date
|
class Date
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
short day;
|
short day_;
|
||||||
short month;
|
short month_;
|
||||||
unsigned int year;
|
unsigned int year_;
|
||||||
public:
|
public:
|
||||||
Date() : day(1), month(1), year(1900)
|
Date() : day_(1), month_(1), year_(1900)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Date(short day, short month, unsigned int year) : day(day), month(month), year(year)
|
Date(short day, short month, unsigned int year) : day_(day), month_(month), year_(year)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,15 +39,17 @@ public:
|
|||||||
tm date{};
|
tm date{};
|
||||||
localtime_s(&date, ×tamp);
|
localtime_s(&date, ×tamp);
|
||||||
const auto current_year = date.tm_year + 1900;
|
const auto current_year = date.tm_year + 1900;
|
||||||
return current_year - year;
|
return current_year - year_;
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_birthday() const
|
string get_birthday() const
|
||||||
{
|
{
|
||||||
return std::to_string(day) + "." + to_string(month) + "." + to_string(year);
|
return std::to_string(day_) + "." + to_string(month_) + "." + to_string(year_);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
bool operator ==(const Date& d) const { return day_ == d.day_ && month_ == d.month_ && year_ == d.year_; }
|
||||||
|
bool operator !=(const Date& d) const { return !operator==(d); }
|
||||||
|
};
|
||||||
|
|
||||||
class employee
|
class employee
|
||||||
{
|
{
|
||||||
@ -82,6 +84,13 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator ==(const employee& e) const
|
||||||
|
{
|
||||||
|
return name == e.name && first_name == e.first_name && day_of_birth == e.day_of_birth;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator !=(const employee& e) const { return !operator==(e); }
|
||||||
|
|
||||||
string name;
|
string name;
|
||||||
string first_name;
|
string first_name;
|
||||||
Date day_of_birth;
|
Date day_of_birth;
|
||||||
@ -90,12 +99,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static list<employee> employees;
|
static list<employee> employees;
|
||||||
|
|
||||||
void create_employee();
|
void create_employee();
|
||||||
|
employee* search_employee();
|
||||||
employee search_employee();
|
|
||||||
|
|
||||||
void list_employees();
|
void list_employees();
|
||||||
|
void modify_employee();
|
||||||
|
void print_employee(employee employee);
|
||||||
|
void enter_holidays(employee& employee);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -106,10 +115,8 @@ int main()
|
|||||||
cout << "Urlaubsverwaltung (" << employees.size() << " Mitarbeiter)" << endl << endl;
|
cout << "Urlaubsverwaltung (" << employees.size() << " Mitarbeiter)" << endl << endl;
|
||||||
cout << "Bitte w\x84hlen 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\x94schen" << endl;
|
cout << "2: Mitarbeiter bearbeiten" << endl;
|
||||||
cout << "3: Urlaub eingeben" << endl;
|
cout << "3: Alle Mitarbeiter auflisten" << endl;
|
||||||
cout << "4: Mitarbeiter suchen" << endl;
|
|
||||||
cout << "5: Alle Mitarbeiter auflisten" << endl;
|
|
||||||
cout << "0: Programm beenden" << endl;
|
cout << "0: Programm beenden" << endl;
|
||||||
cout << "ihre Eingabe:";
|
cout << "ihre Eingabe:";
|
||||||
auto input = 0;
|
auto input = 0;
|
||||||
@ -121,13 +128,9 @@ int main()
|
|||||||
create_employee();
|
create_employee();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
modify_employee();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
search_employee();
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
list_employees();
|
list_employees();
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
@ -138,7 +141,7 @@ int main()
|
|||||||
system("pause");
|
system("pause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_employee()
|
void create_employee()
|
||||||
{
|
{
|
||||||
@ -168,40 +171,100 @@ void create_employee()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void modify_employee(employee employee);
|
|
||||||
|
|
||||||
employee search_employee()
|
employee* search_employee()
|
||||||
{
|
{
|
||||||
|
if (employees.empty()) throw 1;
|
||||||
string name;
|
string name;
|
||||||
cout << "Bitte einen Namen eingeben: ";
|
cout << "Bitte einen Namen eingeben: ";
|
||||||
cin >> name;
|
cin >> name;
|
||||||
string first_name;
|
string first_name;
|
||||||
cout << "Bitte einen Vornamen eingeben: ";
|
cout << "Bitte einen Vornamen eingeben: ";
|
||||||
cin >> first_name;
|
cin >> first_name;
|
||||||
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))
|
||||||
{
|
{
|
||||||
return e;
|
return &e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return employee{};
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void list_employees()
|
void list_employees()
|
||||||
{
|
{
|
||||||
for (const auto& employee : employees)
|
for (auto& employee : employees)
|
||||||
{
|
{
|
||||||
cout << " First name: " << employee.first_name << " Name: " << employee.name << endl;
|
print_employee(employee);
|
||||||
cout << " Birthday: " << employee.day_of_birth.get_birthday() << endl;
|
|
||||||
cout << " Holidays: " << employee.holidays << " Taken Holidays: " << employee.taken_holidays << endl;
|
|
||||||
cout << "--------------------------------" << endl;
|
|
||||||
}
|
}
|
||||||
system("pause");
|
system("pause");
|
||||||
}
|
}
|
||||||
|
|
||||||
void modify_employee(employee employee)
|
void modify_employee()
|
||||||
|
{
|
||||||
|
auto end_program = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto current = search_employee();
|
||||||
|
|
||||||
|
while (!end_program)
|
||||||
|
{
|
||||||
|
system("cls");
|
||||||
|
print_employee(*current);
|
||||||
|
cout << "Bitte w\x84hlen Sie eine Option:" << endl;
|
||||||
|
cout << "1: Urlaub eingeben" << endl;
|
||||||
|
cout << "2: Mitarbeiter l\x94schen" << endl;
|
||||||
|
cout << "0: Zurueck" << endl;
|
||||||
|
cout << "Ihre Eingabe:";
|
||||||
|
auto input = 0;
|
||||||
|
cin >> input;
|
||||||
|
|
||||||
|
switch (input)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
enter_holidays(*current);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
employees.remove(*current);
|
||||||
|
cout << "Benutzer gel\x94scht";
|
||||||
|
system("pause");
|
||||||
|
end_program = true;
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
end_program = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cout << "Unerlaubte Eingabe" << endl;
|
||||||
|
system("pause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (int 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;
|
||||||
|
}
|
||||||
|
system("pause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_employee(employee employee)
|
||||||
|
{
|
||||||
|
cout << " " << employee.first_name << employee.name << endl;
|
||||||
|
cout << " Geburtstag: " << employee.day_of_birth.get_birthday() << endl;
|
||||||
|
cout << " Urlaub: " << employee.holidays << " Genehmigter Urlaub: " << employee.taken_holidays << endl;
|
||||||
|
cout << "--------------------------------" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void enter_holidays(employee& employee)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user