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