comments...
This commit is contained in:
parent
c5d7a7eb60
commit
89431aa4c5
@ -324,22 +324,36 @@ public:
|
|||||||
return customer_;
|
return customer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Cancel reservation -> Give Motorcycle to the customer
|
||||||
|
*/
|
||||||
void cancel_reservation()
|
void cancel_reservation()
|
||||||
{
|
{
|
||||||
canceled_ = true;
|
canceled_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get Id of the item
|
||||||
|
* \return Auto-incremented id as integer
|
||||||
|
*/
|
||||||
int get_id() const
|
int get_id() const
|
||||||
{
|
{
|
||||||
return id_;
|
return id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief get cancellation status of the reservation
|
||||||
|
* \return True is canceled. False otherwise.
|
||||||
|
*/
|
||||||
bool get_cancellation() const
|
bool get_cancellation() const
|
||||||
{
|
{
|
||||||
return canceled_;
|
return canceled_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief All available motorcycles
|
||||||
|
*/
|
||||||
string motorcycles[] =
|
string motorcycles[] =
|
||||||
{
|
{
|
||||||
"Suzuki Bandit",
|
"Suzuki Bandit",
|
||||||
@ -348,14 +362,39 @@ string motorcycles[] =
|
|||||||
"Kawasaki ZZR1400"
|
"Kawasaki ZZR1400"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Collection of customer-pointers
|
||||||
|
*/
|
||||||
list<customer*> customers;
|
list<customer*> customers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Collection of reservation pointers.
|
||||||
|
*/
|
||||||
list<reservation*> reservations;
|
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_customer();
|
||||||
void create_reservation();
|
void create_reservation();
|
||||||
void rent_a_motorcycle();
|
void rent_a_motorcycle();
|
||||||
void export_reservations();
|
void export_reservations();
|
||||||
|
void main_menu();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Main entry method. Starts the main menu.
|
||||||
|
* \return success code
|
||||||
|
*/
|
||||||
int main()
|
int main()
|
||||||
|
{
|
||||||
|
main_menu();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Let the user choice an option.
|
||||||
|
*/
|
||||||
|
void main_menu()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -389,7 +428,9 @@ int main()
|
|||||||
export_reservations();
|
export_reservations();
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
return 0;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
cout << "Unerlaubte Eingabe" << endl;
|
cout << "Unerlaubte Eingabe" << endl;
|
||||||
system("pause");
|
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()
|
void create_customer()
|
||||||
{
|
{
|
||||||
while (true)
|
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*> find_customers_by_name(const string& name)
|
||||||
{
|
{
|
||||||
vector<customer*> result;
|
vector<customer*> result;
|
||||||
@ -437,6 +487,29 @@ vector<customer*> find_customers_by_name(const string& name)
|
|||||||
return result;
|
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)
|
date get_validated_date(const string&& question)
|
||||||
{
|
{
|
||||||
while (true)
|
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()
|
int select_motorcycle()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user