comments...

This commit is contained in:
Holger Börchers 2018-12-29 14:22:02 +01:00
parent c5d7a7eb60
commit 89431aa4c5

View File

@ -324,22 +324,36 @@ public:
return customer_;
}
/**
* \brief Cancel reservation -> Give Motorcycle to the customer
*/
void cancel_reservation()
{
canceled_ = true;
}
/**
* \brief Get Id of the item
* \return Auto-incremented id as integer
*/
int get_id() const
{
return id_;
}
/**
* \brief get cancellation status of the reservation
* \return True is canceled. False otherwise.
*/
bool get_cancellation() const
{
return canceled_;
}
};
/**
* \brief All available motorcycles
*/
string motorcycles[] =
{
"Suzuki Bandit",
@ -348,14 +362,39 @@ string motorcycles[] =
"Kawasaki ZZR1400"
};
/**
* \brief Collection of customer-pointers
*/
list<customer*> customers;
/**
* \brief Collection of reservation pointers.
*/
list<reservation*> reservations;
/**
* \brief Creates a new customer, let the user check the input and push it on the list.
*/
void create_customer();
void create_reservation();
void rent_a_motorcycle();
void export_reservations();
void main_menu();
/**
* \brief Main entry method. Starts the main menu.
* \return success code
*/
int main()
{
main_menu();
return 0;
}
/**
* \brief Let the user choice an option.
*/
void main_menu()
{
try
{
@ -389,7 +428,9 @@ int main()
export_reservations();
break;
case 0:
return 0;
{
return;
}
default:
cout << "Unerlaubte Eingabe" << endl;
system("pause");
@ -403,6 +444,10 @@ int main()
}
}
/**
* \brief Creates a new customer, let the user check the input and push it on the list.
*/
void create_customer()
{
while (true)
@ -424,6 +469,11 @@ void create_customer()
}
/**
* \brief Finds customers by last name
* \param name Last name
* \return Returns a vector of customers with the same last name
*/
vector<customer*> find_customers_by_name(const string& name)
{
vector<customer*> result;
@ -437,6 +487,29 @@ vector<customer*> find_customers_by_name(const string& name)
return result;
}
/**
* \brief Find the first customer by first name.
* \param filtered_customers A vector of customers with the same last name
* \param first_name The first name
* \return The first customer with the matching first name. If no customer found, it returns a nullptr
*/
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;
}
/**
* \brief Gets the validated date
* \param question Question to ask the user
* \return A date object.
*/
date get_validated_date(const string&& question)
{
while (true)
@ -461,18 +534,6 @@ date get_validated_date(const string&& question)
}
}
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;
}
int select_motorcycle()
{
while (true)