working on validation

This commit is contained in:
Holger Börchers 2018-12-26 22:33:22 +01:00
parent 6c03201662
commit f7e90c0eab

View File

@ -352,13 +352,16 @@ int select_motorcycle()
bool validate_reservation(reservation* const reservation) bool validate_reservation(reservation* const reservation)
{ {
const auto start_sum = reservation->get_start_date().get_sum();
const auto end_sum = reservation->get_end_date().get_sum();
for (auto r : reservations) for (auto r : reservations)
{ {
if (r->get_motorcycle() == reservation->get_motorcycle()) if (r->get_motorcycle() == reservation->get_motorcycle())
{ {
if (reservation->get_start_date().get_sum() > r->get_end_date().get_sum()) if (start_sum < r->get_end_date().get_sum() && end_sum > r->get_start_date().get_sum()
|| end_sum > r->get_start_date().get_sum() && end_sum < r->get_end_date().get_sum())
{ {
//TODO return false;
} }
} }
} }
@ -401,6 +404,12 @@ void create_reservation()
{ {
reservations.push_back(r); reservations.push_back(r);
} }
else
{
cout << "Reservierung konnte nicht angelegt werden." << endl;
cout << "Die Zeitperiode ueberschneidet sich mit einer vorhandenen Reservierung" << endl;
system("pause");
}
} }
void rent_a_motorcycle() void rent_a_motorcycle()