comments and reorganization

This commit is contained in:
Holger Börchers 2018-12-29 14:30:26 +01:00
parent 89431aa4c5
commit f3a349f7cf

View File

@ -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
*/ */
@ -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;