comments and reorganization
This commit is contained in:
parent
89431aa4c5
commit
f3a349f7cf
@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int next_customer_id;
|
|
||||||
int next_reservation_id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief ask a question and get a answer.
|
* \brief ask a question and get a answer.
|
||||||
* \tparam T return parameter
|
* \tparam T return parameter
|
||||||
@ -53,7 +50,7 @@ bool ask_question(const string& question)
|
|||||||
* \param digits Number of digits to fill
|
* \param digits Number of digits to fill
|
||||||
* \return Formatted integer as string
|
* \return Formatted integer as string
|
||||||
*/
|
*/
|
||||||
auto int_to_string(const unsigned int value, const unsigned int digits = 0) -> string
|
string int_to_string(const unsigned int value, const unsigned int digits = 0)
|
||||||
{
|
{
|
||||||
auto str = to_string(value);
|
auto str = to_string(value);
|
||||||
const auto len = digits > str.length() ? digits - str.length() : 0;
|
const auto len = digits > str.length() ? digits - str.length() : 0;
|
||||||
@ -172,6 +169,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Incremental raised number as id for customer.
|
||||||
|
*/
|
||||||
|
int next_customer_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Customer, represented by name, first name, address, phone and year of birth
|
* \brief Customer, represented by name, first name, address, phone and year of birth
|
||||||
*/
|
*/
|
||||||
@ -266,6 +268,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Incremental raised number as id for a reservation.
|
||||||
|
*/
|
||||||
|
int next_reservation_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Reservation of a motorcycle
|
* \brief Reservation of a motorcycle
|
||||||
*/
|
*/
|
||||||
@ -388,7 +395,7 @@ void main_menu();
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
main_menu();
|
main_menu();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -396,52 +403,52 @@ int main()
|
|||||||
*/
|
*/
|
||||||
void main_menu()
|
void main_menu()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
system("cls");
|
system("cls");
|
||||||
cout << "Motorradvermietung (" << reservations.size() << " Reservierungen; " << customers.size() <<
|
cout << "Motorradvermietung (" << reservations.size() << " Reservierungen; " << customers.size() <<
|
||||||
" Kunden)"
|
" Kunden)"
|
||||||
<< endl << endl;
|
<< endl << endl;
|
||||||
cout << "Bitte w\x84hlen Sie eine Option:" << endl;
|
cout << "Bitte w\x84hlen Sie eine Option:" << endl;
|
||||||
cout << "1: Neuen Kunden anlegen" << endl;
|
cout << "1: Neuen Kunden anlegen" << endl;
|
||||||
cout << "2: Erstellen einer Reservierung" << endl;
|
cout << "2: Erstellen einer Reservierung" << endl;
|
||||||
cout << "3: Motorrad herausgeben" << endl;
|
cout << "3: Motorrad herausgeben" << endl;
|
||||||
cout << "4: Reservierungen exportieren" << endl;
|
cout << "4: Reservierungen exportieren" << endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << "0: Programm beenden" << endl;
|
cout << "0: Programm beenden" << endl;
|
||||||
const auto input = ask_question<int>("Ihre Eingabe");
|
const auto input = ask_question<int>("Ihre Eingabe");
|
||||||
|
|
||||||
switch (input)
|
switch (input)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
create_customer();
|
create_customer();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
create_reservation();
|
create_reservation();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
rent_a_motorcycle();
|
rent_a_motorcycle();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
export_reservations();
|
export_reservations();
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
cout << "Unerlaubte Eingabe" << endl;
|
cout << "Unerlaubte Eingabe" << endl;
|
||||||
system("pause");
|
system("pause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
cout << "Etwas unvorhergesehendes ist passiert. Tut mir leid." << endl;
|
cout << "Etwas unvorhergesehendes ist passiert. Tut mir leid." << endl;
|
||||||
system("pause");
|
system("pause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -495,14 +502,14 @@ vector<customer*> find_customers_by_name(const string& name)
|
|||||||
*/
|
*/
|
||||||
customer* find_customer_by_first_name(const vector<customer*>& filtered_customers, const string& first_name)
|
customer* find_customer_by_first_name(const vector<customer*>& filtered_customers, const string& first_name)
|
||||||
{
|
{
|
||||||
for (auto c : filtered_customers)
|
for (auto c : filtered_customers)
|
||||||
{
|
{
|
||||||
if (c->get_first_name() == first_name)
|
if (c->get_first_name() == first_name)
|
||||||
{
|
{
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -534,6 +541,10 @@ date get_validated_date(const string&& question)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
int select_motorcycle()
|
int select_motorcycle()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@ -544,9 +555,8 @@ int select_motorcycle()
|
|||||||
{
|
{
|
||||||
cout << ++index << ": " << cycle << endl;
|
cout << ++index << ": " << cycle << endl;
|
||||||
}
|
}
|
||||||
const auto answer = ask_question<unsigned int>("Auswahl");
|
const auto answer = ask_question<int>("Auswahl");
|
||||||
const auto size = static_cast<int>(sizeof(motorcycles) / sizeof(*motorcycles));
|
if (answer > 0 && answer <= index)
|
||||||
if (answer > 0 && answer <= size)
|
|
||||||
{
|
{
|
||||||
return answer - 1;
|
return answer - 1;
|
||||||
}
|
}
|
||||||
@ -599,6 +609,7 @@ void create_reservation()
|
|||||||
system("pause");
|
system("pause");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
cout << "Kunde gefunden: " << current->get_first_name() << " " << current->get_name() << endl;
|
||||||
if (!current->get_has_driving_license())
|
if (!current->get_has_driving_license())
|
||||||
{
|
{
|
||||||
cout << "Der Kunde hat keinen entsprechenden Fuehrerschein." << endl;
|
cout << "Der Kunde hat keinen entsprechenden Fuehrerschein." << endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user