Compare commits
No commits in common. "0040965d2f693d3b91ad1516cc7bae70a2215bd2" and "1460e820ee11b5e7e933882d8f627999e4a2a1a7" have entirely different histories.
0040965d2f
...
1460e820ee
@ -20,15 +20,15 @@ using namespace std;
|
||||
class Date
|
||||
{
|
||||
private:
|
||||
short day_;
|
||||
short month_;
|
||||
unsigned int year_;
|
||||
short day;
|
||||
short month;
|
||||
unsigned int year;
|
||||
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,18 +39,16 @@ public:
|
||||
tm date{};
|
||||
localtime_s(&date, ×tamp);
|
||||
const auto current_year = date.tm_year + 1900;
|
||||
return current_year - year_;
|
||||
return current_year - year;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
private:
|
||||
@ -84,13 +82,6 @@ public:
|
||||
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 first_name;
|
||||
Date day_of_birth;
|
||||
@ -99,12 +90,12 @@ public:
|
||||
};
|
||||
|
||||
static list<employee> employees;
|
||||
|
||||
void create_employee();
|
||||
employee* search_employee();
|
||||
|
||||
employee search_employee();
|
||||
|
||||
void list_employees();
|
||||
void modify_employee();
|
||||
void print_employee(employee employee);
|
||||
void enter_holidays(employee& employee);
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -115,8 +106,10 @@ int main()
|
||||
cout << "Urlaubsverwaltung (" << employees.size() << " Mitarbeiter)" << endl << endl;
|
||||
cout << "Bitte w\x84hlen Sie eine Option:" << endl;
|
||||
cout << "1: Mitarbeiter anlegen" << endl;
|
||||
cout << "2: Mitarbeiter bearbeiten" << endl;
|
||||
cout << "3: Alle Mitarbeiter auflisten" << endl;
|
||||
cout << "2: Mitarbeiter l\x94schen" << endl;
|
||||
cout << "3: Urlaub eingeben" << endl;
|
||||
cout << "4: Mitarbeiter suchen" << endl;
|
||||
cout << "5: Alle Mitarbeiter auflisten" << endl;
|
||||
cout << "0: Programm beenden" << endl;
|
||||
cout << "ihre Eingabe:";
|
||||
auto input = 0;
|
||||
@ -128,9 +121,13 @@ int main()
|
||||
create_employee();
|
||||
break;
|
||||
case 2:
|
||||
modify_employee();
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
search_employee();
|
||||
break;
|
||||
case 5:
|
||||
list_employees();
|
||||
break;
|
||||
case 0:
|
||||
@ -171,100 +168,40 @@ void create_employee()
|
||||
}
|
||||
}
|
||||
|
||||
void modify_employee(employee employee);
|
||||
|
||||
employee* search_employee()
|
||||
employee search_employee()
|
||||
{
|
||||
if (employees.empty()) throw 1;
|
||||
string name;
|
||||
cout << "Bitte einen Namen eingeben: ";
|
||||
cin >> name;
|
||||
string first_name;
|
||||
cout << "Bitte einen Vornamen eingeben: ";
|
||||
cin >> first_name;
|
||||
for (auto& e : employees)
|
||||
for (auto e : employees)
|
||||
{
|
||||
if (e.first_name._Equal(first_name) && e.name._Equal(name))
|
||||
{
|
||||
return &e;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
throw 0;
|
||||
return employee{};
|
||||
}
|
||||
|
||||
|
||||
void list_employees()
|
||||
{
|
||||
for (auto& employee : employees)
|
||||
for (const auto& employee : employees)
|
||||
{
|
||||
print_employee(employee);
|
||||
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()
|
||||
{
|
||||
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)
|
||||
void modify_employee(employee employee)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user